Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Getting Available Buying Power of Simulation Account from NinjaScript

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

    Getting Available Buying Power of Simulation Account from NinjaScript

    Hello, I am trying to access the various Account information from my strategy code using the GetAccountValue method. However when running my strat under the sim101 account all of the values are 0.

    For instance
    Code:
    GetAccountValue(AccountItem.BuyingPower)
    returns zero.
    Code:
    GetAccountValue(AccountItem.CashValue)
    also returns zero. Shouldn't this return something?

    #2
    Hello spiralhead,

    It returns 0 if accessed on historical or backtest bars. You should get a value if accessed on real time bars. Please let us know if you're not able to see it then.
    Ryan M.NinjaTrader Customer Service

    Comment


      #3
      I figured that might be the case so i tried it on the simulated data feed and it still returned zero. It it supposed to work this way?

      Comment


        #4
        It should work on the simulated data feed, as long as the code is processed on a real-time bar, and not just historical.

        Print(GetAccountValue(AccountItem.CashValue) + " " + Historical);

        If you use the snippet above, would expect that it returns either 0 true or aGoodValue + false.

        May also want to reset the simulated account. Tools > Options > Simulator > Reset
        Ryan M.NinjaTrader Customer Service

        Comment


          #5
          Hi for some reason Historical is always true in the simulator and live data. I'm testing it with live data now and Historical is always=true. I have CalculateOnBarClose=false. What am I doing wrong?

          Comment


            #6
            Actually I think I figured this out. If a strat is currently in a position where the entry was triggered on historical data then historical will always be True.

            Comment


              #7
              Yes, that could explain it, spiralhead. Good catch.

              Tips
              1. When using this property in a strategy that is running with "Wait until flat before executing live", the property will return "true" until the strategy reaches a flat state and switches to live executions.
              Ryan M.NinjaTrader Customer Service

              Comment


                #8
                Originally posted by NinjaTrader_RyanM View Post
                Yes, that could explain it, spiralhead. Good catch.

                Tips
                1. When using this property in a strategy that is running with "Wait until flat before executing live", the property will return "true" until the strategy reaches a flat state and switches to live executions.

                OK I see that setting in the Options. If I have the "Immediately submit live worker historical orders" option set will that actually submit an order to my broker?

                Comment


                  #9
                  What that means is that it will not wait until your strategy reaches a flat state before submitting orders. This doesn't necessarily mean it places orders right away, but that the next exit signal received could be submitted, potentially leading to sync issues with your account and strategy position.

                  Ryan M.NinjaTrader Customer Service

                  Comment

                  Latest Posts

                  Collapse

                  Topics Statistics Last Post
                  Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                  0 responses
                  646 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