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 Geovanny Suaza, 02-11-2026, 06:32 PM
      0 responses
      650 views
      0 likes
      Last Post Geovanny Suaza  
      Started by Geovanny Suaza, 02-11-2026, 05:51 PM
      0 responses
      370 views
      1 like
      Last Post Geovanny Suaza  
      Started by Mindset, 02-09-2026, 11:44 AM
      0 responses
      109 views
      0 likes
      Last Post Mindset
      by Mindset
       
      Started by Geovanny Suaza, 02-02-2026, 12:30 PM
      0 responses
      574 views
      1 like
      Last Post Geovanny Suaza  
      Started by RFrosty, 01-28-2026, 06:49 PM
      0 responses
      577 views
      1 like
      Last Post RFrosty
      by RFrosty
       
      Working...
      X