Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Zero value by GetAccountValue(AccountItem.CashValue)

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

    Zero value by GetAccountValue(AccountItem.CashValue)

    Hello!

    I would really appreciate it if someone could advise me with the issue as follows:
    I programmed a strategy and I intended to implement a money management method.
    As I require the current cash value status on a five minute timeframe to develop a money management logic in there I used the expression GetAccountValue(AccountItem.CashValue).
    The problem is that this command returns always "0" zero after every bar even if my accounts status at the control center displays still more than 50 grands. How is that possible? What's the mistake?

    Many thanks.

    Cheers!

    Rob

    #2
    I've noticed that GetAccountValue() only works on live ticks, not historical. Maybe that's your problem?

    Comment


      #3
      Hello Radical!

      Thank you for your reply! I use a CQG real time datafeed but it is an demo account.
      Could this cause the issue?

      Many thanks.

      Rob

      Comment


        #4
        Robert,

        One thing to note is that with GetAccountValue, a value of 0 will be returned on historical bars.
        Adam P.NinjaTrader Customer Service

        Comment


          #5
          Dear NinjaTrader_AdamP!

          Thanks for the reply! Could you please advise me how to find out whether the datafeed I use is based on historical bars or on live ticks? I am currently using a CQG demo account. I assumed that
          the datafeed is based on a live ticks datafeed?

          Many thanks.

          Rob

          Comment


            #6
            Robert,

            Well, any historical data the strategy executes something on would be historical bars. When a strategy is first attached to a chart, it does a backtest to determine what order state it should be in at the present bar.

            In real-time trading, this is when ticks are coming in, if the strategy is executing on this data it would be getting the account value.

            Are you using a simulated license key or a live license key for NinjaTrader?
            Adam P.NinjaTrader Customer Service

            Comment


              #7
              Hello NinjaTrader_AdamP,

              I seems like a simulated license key for ninjatrader! (see email below):
              "
              Thank you for registering for the FREE simulated NinjaTrader/CQG demo.

              Once you have downloaded Ninja Trader, you will be prompted to enter a license key (below) the first time you log in.

              License Key: @AMP-CQG4-D583-40B1-AE74-B79F-705D-7777

              After entering your license key into the software you will need to establish your real time streaming data connection from CQG.

              In order to set this up you will need a user ID and password. This will be emailed to you within 15 minutes.

              1.Start NinjaTrader
              2.From within the Control Center window, Select Tools-->Account Connections
              3.In the Account Connection Set Up window, press Add
              4.Click on Next, name the connection CQG and select CQG as the Provider
              5.Backup data feed connection: ""
              6.Select "Enabled" for historical data
              7.Enter the username/password and check "Demo Mode"
              8.Complete the wizard
              9.From the Control Panel select File->Connect->CQG and give it a few seconds to connect. You will see a green box in the lower left corner of the control panel that says Connected - CQG.

              We encourage you to sign up for another demo account if you are unable to test the trading platform adequately before this account expires.

              For assistance, please contact our office directly."

              Rob

              Comment


                #8
                Hello NinjaTrader_AdamP,

                It that case I assume that even the commands:
                GetAccountValue(AccountItem.BuyingPower);
                and
                GetAccountValue(AccountItem.RealizedProfitLoss);
                won't work with a demo account with CQG, right?

                Many thanks

                Rob

                Comment


                  #9
                  Rob,

                  GetAccountValue will work with the Sim101 account on a Demo account.

                  The reason it is returned as 0 is because the strategy (regardless if it is a live or demo account) will calculate on historical data first. This will always return a value of 0.

                  Once the strategy starts operating on real-time data from your CQG Demo, you should see the proper Account Value from this function.

                  If your strategy is started as CalculateOnBarClose = true, you will not see GetAccountValue return the account value until the next bar forms. So on a 5 minute chart, you would need to wait until the next 5 minute bar to close. If you change the strategy to CalculateOnBarClose = false, GetAccountValue will return as soon as you get an incoming tick.

                  As an exercise, please try adding a Print statement for historical bars to get an idea when the strategy is running on historical bars, vs real-time bars

                  Code:
                  Print(Time[0] + " " + Historical);
                  This would return the time of the current bar, and True when your strategy is processing historical bars, and then False when the strategy starts processing on real-time data.

                  Please review our Help Guide article on the Historical data property for more information:

                  MatthewNinjaTrader Product Management

                  Comment


                    #10
                    Does GetAccountValue(AccountItem.CashValue) works in market replay?

                    Comment


                      #11
                      Rob, you would be able to access the values in realtime that your brokerage technology would offer you, so if you check your CQG demo account in NT's Accounts tab when connected, you would see CashValue being populated > this is then what GetAccountValue could access as well in your script.

                      Comment

                      Latest Posts

                      Collapse

                      Topics Statistics Last Post
                      Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                      0 responses
                      670 views
                      0 likes
                      Last Post Geovanny Suaza  
                      Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                      0 responses
                      379 views
                      1 like
                      Last Post Geovanny Suaza  
                      Started by Mindset, 02-09-2026, 11:44 AM
                      0 responses
                      111 views
                      0 likes
                      Last Post Mindset
                      by Mindset
                       
                      Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                      0 responses
                      575 views
                      1 like
                      Last Post Geovanny Suaza  
                      Started by RFrosty, 01-28-2026, 06:49 PM
                      0 responses
                      582 views
                      1 like
                      Last Post RFrosty
                      by RFrosty
                       
                      Working...
                      X