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 giulyko00, Today, 12:03 PM
                  0 responses
                  2 views
                  0 likes
                  Last Post giulyko00  
                  Started by AttiM, 02-14-2024, 05:20 PM
                  12 responses
                  213 views
                  0 likes
                  Last Post DrakeiJosh  
                  Started by cre8able, 02-11-2023, 05:43 PM
                  3 responses
                  238 views
                  0 likes
                  Last Post rhubear
                  by rhubear
                   
                  Started by frslvr, 04-11-2024, 07:26 AM
                  8 responses
                  117 views
                  1 like
                  Last Post NinjaTrader_BrandonH  
                  Started by stafe, 04-15-2024, 08:34 PM
                  10 responses
                  47 views
                  0 likes
                  Last Post stafe
                  by stafe
                   
                  Working...
                  X