Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

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 usazencort, Today, 01:16 AM
                  0 responses
                  1 view
                  0 likes
                  Last Post usazencort  
                  Started by kaywai, 09-01-2023, 08:44 PM
                  5 responses
                  603 views
                  0 likes
                  Last Post NinjaTrader_Jason  
                  Started by xiinteractive, 04-09-2024, 08:08 AM
                  6 responses
                  22 views
                  0 likes
                  Last Post xiinteractive  
                  Started by Pattontje, Yesterday, 02:10 PM
                  2 responses
                  20 views
                  0 likes
                  Last Post Pattontje  
                  Started by flybuzz, 04-21-2024, 04:07 PM
                  17 responses
                  230 views
                  0 likes
                  Last Post TradingLoss  
                  Working...
                  X