Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

GetAccountValue

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

    GetAccountValue

    I have the following code that I run on the first bar:

    string accnt = "&accnt=" + GetAccountValue(AccountItem.CashValue).ToString() + ":"
    + GetAccountValue(AccountItem.RealizedProfitLoss).To String();
    Print( accnt );

    string trd = "&trd=" + Position.GetProfitLoss(Close[0], PerformanceUnit.Points).ToString() + ":"
    + Position.Quantity.ToString() + ":"
    + Instrument.FullName.Split(' ')[0] + ":"
    + Position.AvgPrice.ToString() + ":" + Close[0];

    GetAccountValue has a value of zero even though it is a valid and funded account. Does this call work or am I doing something wrong? I also would like to get the account number. And I want to check that if I call Polistion.Quantity I will get the number of contracts being traded?

    I searched the help and the forum but no one else seems to have this problem.

    #2
    I found one of my own answers. GetAccountValue is always zero on Historical bars. Can I still get an answer on account number and number of contracts? Thanks.

    Originally posted by tradetree View Post
    I have the following code that I run on the first bar:

    string accnt = "&accnt=" + GetAccountValue(AccountItem.CashValue).ToString() + ":"
    + GetAccountValue(AccountItem.RealizedProfitLoss).To String();
    Print( accnt );

    string trd = "&trd=" + Position.GetProfitLoss(Close[0], PerformanceUnit.Points).ToString() + ":"
    + Position.Quantity.ToString() + ":"
    + Instrument.FullName.Split(' ')[0] + ":"
    + Position.AvgPrice.ToString() + ":" + Close[0];

    GetAccountValue has a value of zero even though it is a valid and funded account. Does this call work or am I doing something wrong? I also would like to get the account number. And I want to check that if I call Polistion.Quantity I will get the number of contracts being traded?

    I searched the help and the forum but no one else seems to have this problem.

    Comment


      #3
      Correct, it would be 0 for historical bars - as this is a real-time only property.

      Position.Quantity is the current qty of the strategy position, and would not be tied to the account.

      Not documented / supported, but Account.Name should let you check for the account string.

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by charlesugo_1, 05-26-2026, 05:03 PM
      0 responses
      66 views
      0 likes
      Last Post charlesugo_1  
      Started by DannyP96, 05-18-2026, 02:38 PM
      1 response
      149 views
      0 likes
      Last Post NinjaTrader_ChelseaB  
      Started by CarlTrading, 05-11-2026, 05:56 AM
      0 responses
      162 views
      0 likes
      Last Post CarlTrading  
      Started by CarlTrading, 05-10-2026, 08:12 PM
      0 responses
      99 views
      0 likes
      Last Post CarlTrading  
      Started by Hwop38, 05-04-2026, 07:02 PM
      0 responses
      286 views
      0 likes
      Last Post Hwop38
      by Hwop38
       
      Working...
      X