Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

AccountSize

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

    AccountSize

    OK, what I've been able to decipher from reading previous posts is that you cannot dynamically (eg. live trading) query your broker to see what your account size is (cash value).

    I see that you can set the "AccountSize" property to a value in the strategy initialize function. And I think it will accurately reflect the profit/losses once the strategy starts trading.

    But I still have a couple questions I need clarification on:

    1) What happens if I'm trading the same strategy on multiple markets (charts)? Does the AccountSize accurately span all instruments?

    So for example, let's say I never want to have more than 6% of my account at risk at any given moment AND I don't want to place a new trade if my account size is down 6% for the day.

    So when one of my strategies is about to place a trade, I would like to see where my account stands as far as:

    1) AccountSize (spanning all charts)
    2) Open positions (spanning all charts)

    Is this something that NT has the ability of tracking? Or will I need to code something myself to keep track of all orders and my over-all account size?

    Thanks

    #2
    1. A single instance of a strategy has one AccountSize that will be accurate across all the instruments in that strategy. Running a strategy as multiple instances across several different charts means you will have multiple AccountSizes corresponding to each strategy instance.

    2. Open positions for a particular strategy instance is available. Getting positions from other strategies is not supported.
    Josh P.NinjaTrader Customer Service

    Comment


      #3
      Josh,

      Will the AccountSize change? I have it set in a strategy and it's not showing accumulated profits/losses.

      Ex. I set it to 5k in the Init()
      After a trade, I check it in logic (OnBarUpdate) and it's still 5k?

      Thanks

      Comment


        #4
        It changes once you finish the trade. Not when you are in the trade.
        Josh P.NinjaTrader Customer Service

        Comment


          #5
          Not working.

          If I look at the Strategy tab after several trades, it's showing a Realized gain of $110, but the AccountSize is still returning 5k.

          I am using Market Replay - not sure if that has anything to do with it?

          Comment


            #6
            Hello,

            I am jumping in here, and very well may be wrong, but could the difference be reflecting the unrealized loss you are carrying?
            DenNinjaTrader Customer Service

            Comment


              #7
              Not sure I'm following (sorry)...

              I am trading in a sim account - not sure if that has anything to do with it? I tried my strategy this morning on live data and I'm still not getting an accurate AccountSize.

              Here's how I'm entering a trade (short example):

              EnterShort(numContracts, _lastSignal);

              I set the numContracts based on my risk management, and _lastSignal is just a variable where I concatenate "Short" + CurrentBar.

              Any other ideas?

              Thanks

              Comment


                #8
                You need to set the AccountSize either in the strategy selection dialogue box or in your code. Then when you run the strategy, you need to select ByAccountSize for the Order Quantity option.
                Josh P.NinjaTrader Customer Service

                Comment


                  #9
                  Thxs Josh - I'm not trying to use the built in ByAccountSize functionality, I'm just trying to get the AccountSize variable to reflect profits/losses from each trade I take.

                  I'm setting AccountSize in my Init()... then after each trade (realized) it should reflect the cumulative account size but it won't change...

                  Comment


                    #10
                    You may be better served creating your own variable to track this then.
                    Josh P.NinjaTrader Customer Service

                    Comment


                      #11
                      Yeah, was thinking that too. Thanks!

                      Comment


                        #12
                        I ran into this issue a few months ago as well. I think the documentation should be enhanced to specifically state that AccountSize only represents the "starting" sccount size, and does not update as trades progress/complete. See:

                        Comment


                          #13
                          AccountSize does update when you tell your strategy to trade by account size.
                          Josh P.NinjaTrader Customer Service

                          Comment


                            #14
                            I've seen it stated several times that AccountSize auto-updates, but it doesn't seem to update for me. Try this test case, for example:
                            • Save a copy of @SampleMACrossOver.cs as AccountSize.cs
                            • Name the new class AccountSizeStrategy, add this to OnBarUpdate:
                              Code:
                                Print("AccountSize: " + AccountSize); // Add this
                            • Compile the strategy in NT 6.5
                            • Connect to Yahoo data feed
                            • File, New, Strategy Analyzer
                            • DOW30, MSFT, Backtest, AccountSizeStrategy, 1-day bars
                            • Set position size to "by account size", AccountSize to 10000
                            • Run the backtest from 2009-01-01 to today

                            Result in the Log:
                            Code:
                            AccountSize: 10000
                            AccountSize: 10000
                            AccountSize: 10000
                            AccountSize: 10000
                            AccountSize: 10000
                            AccountSize: 10000
                            AccountSize: 10000
                            AccountSize: 10000
                            AccountSize: 10000
                            AccountSize: 10000
                            [keeps going...]
                            Several winning and losing trades complete during the backtest, but the AccountSize does not change. What am I doing wrong here? Does it only work for non Back* accounts, or only in market replay or live? Or is this a bug? I'm running the latest NT 6.5 release.

                            Currently, the docs say that the "Order size is dynamically calculated", not that the AccountSize itself ever changes. Whether it ever does or not, I think the docs should be more specific on this point.
                            Last edited by Anagoge; 08-19-2009, 06:20 PM.

                            Comment


                              #15
                              Try using DefaultQuantity for the Enter() orders.
                              Josh P.NinjaTrader Customer Service

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                              0 responses
                              647 views
                              0 likes
                              Last Post Geovanny Suaza  
                              Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                              0 responses
                              367 views
                              1 like
                              Last Post Geovanny Suaza  
                              Started by Mindset, 02-09-2026, 11:44 AM
                              0 responses
                              108 views
                              0 likes
                              Last Post Mindset
                              by Mindset
                               
                              Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                              0 responses
                              570 views
                              1 like
                              Last Post Geovanny Suaza  
                              Started by RFrosty, 01-28-2026, 06:49 PM
                              0 responses
                              573 views
                              1 like
                              Last Post RFrosty
                              by RFrosty
                               
                              Working...
                              X