Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

trade qty based on account size.

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    trade qty based on account size.

    I'd like my strategy to calculate a trade qty based on the AccountSize. ... https://ninjatrader.com/support/help...ccountsize.htm

    do I need to set this manually at the start and also update its value as trading progresses?​

    #2
    Hello fingers,

    Thank you for your post.

    Unfortunately, AccountSize property is not available in NinjaTrader 8. However, you can calculate this with custom logic.

    Please see the forum post below:



    If you have any other questions, please let us know.

    Comment


      #3
      ok thanks, am I right that this is into add-on territory? but right now, from within the strategy, I can't get get an account balance on which to base trade qty?
      Last edited by fingers; 12-07-2023, 06:26 AM.

      Comment


        #4
        Hello,

        Yes, this is through the Add On approach, but it can be used in any script type including a strategy.

        Comment


          #5
          again thanks for your help. Do you know if there are any samples that do something similar?

          Comment


            #6
            Hello fingers,

            We don't have any examples that demonstrate this specifically, but we do have an example that demonstrates using the Add On approach.

            AddOnFramework - https://ninjatrader.com/support/help...t_overview.htm

            Please let us know if we can assist further.

            Comment


              #7
              I think my question is too involved for this forum and clearly I need to put more effort in my end, fortunately I'm familiar with Visual Studio.

              Thank you.

              Comment


                #8
                trying to base trading qty on account size and getting confused 1.when back testing, 2.when trading historically and 3.when trading real-time.

                should I use:

                protected override void OnAccountItemUpdate(Account account, AccountItem accountItem, double value)

                with AccountItem.BuyingPower

                Comment


                  #9
                  Hello,

                  Yes, use .Get() to get the account's buying power (in realtime).

                  Account.Get(AccountItem.BuyingPower, Currency.UsDollar)

                  .Get() - https://ninjatrader.com/support/helpGuides/nt8/get.htm

                  Unfortunately, there is no historical account information available to access in NinjaScript so you would not be able to get the historical buying power of an account.

                  Comment


                    #10
                    is this a reasonable conclusion?
                    • in backtest with trade size based on account size - the strategy script needs an initial "backtest account size​​" defined and each trade PnL cumulatively +/- the "backtest account size​​" which is then used to calculate the next "backtest trade size​".
                    • in real-time with trade size based on account size - the strategy script (via an add-on) uses Get(AccountItem.CashValue, Currency.UsDollar) to get the actual SIM101 or live account size which is then used to calculate the next trade size.
                    • in historical with trade size based on account size ... same as backtest?​
                    Last edited by fingers; 12-22-2023, 08:44 AM.

                    Comment


                      #11
                      Hello,

                      Yes, since there is no there is no historical account information available to access, you can calculate it that way for backtest/historical using an pre-defined "backtest account size".

                      Please let me know if you have any other questions.

                      Comment


                        #12
                        one last question ...

                        can I detect if the code is running in backtest mode?

                        Comment


                          #13
                          Hello,

                          Yes, you can use IsInStrategyAnalyzer.

                          https://ninjatrader.com/support/help...egyanalyer.htm

                          Comment

                          Latest Posts

                          Collapse

                          Topics Statistics Last Post
                          Started by NullPointStrategies, Today, 05:17 AM
                          0 responses
                          50 views
                          0 likes
                          Last Post NullPointStrategies  
                          Started by argusthome, 03-08-2026, 10:06 AM
                          0 responses
                          126 views
                          0 likes
                          Last Post argusthome  
                          Started by NabilKhattabi, 03-06-2026, 11:18 AM
                          0 responses
                          69 views
                          0 likes
                          Last Post NabilKhattabi  
                          Started by Deep42, 03-06-2026, 12:28 AM
                          0 responses
                          42 views
                          0 likes
                          Last Post Deep42
                          by Deep42
                           
                          Started by TheRealMorford, 03-05-2026, 06:15 PM
                          0 responses
                          46 views
                          0 likes
                          Last Post TheRealMorford  
                          Working...
                          X