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

GetAccountValue(AccountItem.CashValue) returns 0

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

    GetAccountValue(AccountItem.CashValue) returns 0

    Hi there,
    sorry if this may sound as a noob question, i looked at other similar threads on the forum but couldn't find a clear answer.
    I'm developing a strategy and i'm trying to use the GetAccountValue(AccountItem.CashValue) method to retrieve my current balance but it always returns a 0 value.
    I still don't have a data subscription so i'm using the sim101 account connected to the free end of day kinetick, i get the 0 value while backtesting or even if i apply the strategy to a daily chart (initial cash in the options is set to 100.000).
    Am i maybe trying to retrieve my account balance the wrong way?
    Thanks for any help.

    #2
    Hi barbra streisand,

    Thanks for the post and welcome to the NinjaTrader forums. This is a real time value. It will return 0 when accessed historically like backtests. The free connection to Kinetick does not supply real time updates, so this will always return 0.

    You can use the simulated data feed to simulate real time updates. Disconnect from any active feed and then connect using File > Connect > Simulated Data Feed.
    Ryan M.NinjaTrader Customer Service

    Comment


      #3
      Hi Ryan,
      thank you very much for your very quick reply.
      Honestly i can't see the relationship between a data feed and the balance of a simulated account.
      Does your reply mean there's no way to backtest a strategy which uses the account balance to perform calculations?
      Anyway i connected to the simulator, opened a chart and attached my strategy but it still returns 0.
      Thanks.

      Comment


        #4
        There's some values that are only real time. Anything with Get like GetCurrentAsk() will work the same way. Sim101 is a real time account only, so when you backtest it doesn't actually submit trades to this account.

        You can use trade performance values in a backtest, and manually set your own internal variables if you want to track and make calculations on this. The following sample can help get started working with trade performance class.


        It's possible your strategy returns 0 for this value if it's in a "wait until flat" state. To confirm, print Historical and MarketPosition. If Historical is true and you're not flat, then that explains why you are seeing 0.
        Ryan M.NinjaTrader Customer Service

        Comment


          #5
          Hello Support,

          In latest Ninja version is there any method to find current balance in backtesting. Has GetAccountValue(AccountItem.CashValue) been updated to get account balance in backtesting.

          Thanks

          Comment


            #6
            tazz90, there has been no change in this regard - the GetAccountValue would be for realtime use only.
            BertrandNinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by ghoul, Today, 06:02 PM
            3 responses
            13 views
            0 likes
            Last Post NinjaTrader_Manfred  
            Started by jeronymite, 04-12-2024, 04:26 PM
            3 responses
            44 views
            0 likes
            Last Post jeronymite  
            Started by Barry Milan, Yesterday, 10:35 PM
            7 responses
            20 views
            0 likes
            Last Post NinjaTrader_Manfred  
            Started by AttiM, 02-14-2024, 05:20 PM
            10 responses
            180 views
            0 likes
            Last Post jeronymite  
            Started by DanielSanMartin, Yesterday, 02:37 PM
            2 responses
            13 views
            0 likes
            Last Post DanielSanMartin  
            Working...
            X