Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Retrive equity value in account?

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

    Retrive equity value in account?

    I am looking for a way to refer to the current account equity $ value using Ninja Script. I want to used this information for position sizing purposes.

    For example, maybe I never want to risk more than X% of account equity on any new trade, so I need to be able to calculate how many shares/contracts/etc. to purchase/sell in order to stay within that constraint.

    I tried searching the help system for a method that would do this, but I'm not seeing it.

    Thanks.

    #2
    Lawnboy, accessing this live account value is unfortunately not supported for NinjaTrader 6.5, in NinjaTrader 7 we've added methods for this - http://www.ninjatrader.com/webnew/NT7/NinjaTrader7.html

    You could however set an account value used in NT 6.5 - http://www.ninjatrader-support.com/H...countSize.html

    Comment


      #3
      Sorry to hear that. I look forward to seeing NT7.

      Comment


        #4
        AccountSize

        Is the strategy then required to keep track of cash values on each trade entry/exit? I am running into this same problem. I want to size my orders according to how much cash is in the account, but I'm having a hard time figuring out if NT does that for you or you need to do it yourself.

        If I initialize AccountSize in the initialize() do I need to update this variable with each order entry/exit?

        Comment


          #5
          Originally posted by MidnightRider228 View Post
          Is the strategy then required to keep track of cash values on each trade entry/exit? I am running into this same problem. I want to size my orders according to how much cash is in the account, but I'm having a hard time figuring out if NT does that for you or you need to do it yourself.

          If I initialize AccountSize in the initialize() do I need to update this variable with each order entry/exit?
          Yes and yes. NT7 will make this process much easier.
          AustinNinjaTrader Customer Service

          Comment


            #6
            Well then, we are looking forward to NT7!

            Comment


              #7
              I agree

              Yea I agree, cash management, and position sizing in NT6.5 is an abortion. You can still only base your quantity to purchase on the past closing price when backtesting with historical data

              Comment


                #8
                I am using NT7, and it doesn't look like much has changed with AccountSize. Am I correct in stating that there is no way to access the account balance or equity value from within a ninjascript? It is displayed in the "Accounts" tab, so NT has the data. Why is that data not readable from ninjascript? Tradestation has all that data available in their language.

                If what I state is true, then can you calculate the account size by extracting it from "DefaultQuantity"? In other words, if the sizing for buys/sells is set by AccountSize / Current Close Price, then DefaultQuantity x Current Close Price = AccountSize. AccountSize in this case would then be dynamic. What I don't know is if DefaultQuantity can be access as a variable?

                Comment


                  #9
                  TradeTree,

                  This is available through GetAccountValue()

                  Possible values are BuyingPower, CashValue, and RealizedProfitLoss.

                  For using this to determine quantity for orders, you need to code your calculations into a variable, and set order quantity by Strategy. The variable then goes into the order quantity field for your order methods.

                  When using by Default Quantity, it's looking for the value typed in the GUI or assigned by code in the Initialize method. You could assign default quantity as based on these account calculations, but then you lose the ability to dynamically update quantity as your account changes. - Initialize() is only called at the start of the strategy run.
                  Ryan M.NinjaTrader Customer Service

                  Comment


                    #10
                    Thanks. Is there a way to go flat, i.e. sell all outstanding shares? Otherwise you could go short when your just trying to sell your long position.

                    Comment


                      #11
                      With the managed order system, the quantity of exits is determined by the quantity of the entries. Exits are paired with an entry using the fromEntrySignal parameter. If no signal name is specified then it exits all positions opened by the strategy.

                      For more details on this order system, see the following link > How to close a position:
                      Ryan M.NinjaTrader Customer Service

                      Comment


                        #12
                        The value returned for GetAccountValue(AccountItem.CashValue) is zero. The strategy has a valid account selected with a cash balance. I have the "order properties", "set order quantity" = "by strategy". This doesn't even matter, because I simply print out the value of CashValue and it is zero. I also went into the debugger and see the value returned is zero. I do have 3 instruments for a multi-instrument strategy, but this should be independent of instruments. Using NT 7.0.1000.1

                        Comment


                          #13
                          Are you calling this for real time bars? A value of 0 will be returned on historical bars.
                          Ryan M.NinjaTrader Customer Service

                          Comment


                            #14
                            Oh, that's it.

                            Comment


                              #15
                              When is Ninja's idea of these account values updated (for Mirus/RCG)?

                              I have had an account value for 7 hours now that does not reflect an open trade of +600. Furthermore, the balance doesn't equate to any of the figures on RCG's real time account page (it's 160 lower)

                              Normally, I think, the cash value includes open equity?

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                              0 responses
                              650 views
                              0 likes
                              Last Post Geovanny Suaza  
                              Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                              0 responses
                              370 views
                              1 like
                              Last Post Geovanny Suaza  
                              Started by Mindset, 02-09-2026, 11:44 AM
                              0 responses
                              109 views
                              0 likes
                              Last Post Mindset
                              by Mindset
                               
                              Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                              0 responses
                              574 views
                              1 like
                              Last Post Geovanny Suaza  
                              Started by RFrosty, 01-28-2026, 06:49 PM
                              0 responses
                              577 views
                              1 like
                              Last Post RFrosty
                              by RFrosty
                               
                              Working...
                              X