Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
Account value in Indicator
Collapse
X
-
Hello,
Thank you for the question.
This is possible by use of undocumented items. I had posted in a thread about this in the past here: http://ninjatrader.com/support/forum...78&postcount=2
This is a general example that could be modified as needed.
I look forward to being of further assistance.
-
Hi Jesse thanks for the pointer, it appears that the GetAccountValue method still won't compile in the indicator context. This code:
private void StoreAccountValue()
{
foreach (Account acct in Cbi.Globals.Accounts)
{
string acctvalstr = acct.GetAccountValue.ToString();
Print(acctvalstr);
}
}
generates: "method not valid in the given context" Works fine for acct.Name
Is there another way to access the account value using acct. ? Thanks!
Comment
-
Hello,
Thank you for the reply.
Unfortunately the syntax you had provided would still only work in a Strategy but would also need to be valid syntax as shown in the help guide. You have provided only part of the syntax shown in the help guide therefore this would cause a compile error.
For what you are trying to do, because this is a unsupported approach you would need to subscribe to the account values and store these in variables yourself. you would be unable to actively "poll" or request the data at arbitrary times.
Here is a simple example showing Printing the values, again this only happens during an account update event so it would not print unless you connect or place an order or any account related action.
Please let me know if I may be of further assistance.Code:protected override void OnStartUp() { foreach (Account acct in Cbi.Globals.Accounts) { acct.AccountUpdate += Acct_AccountUpdate; } } private void Acct_AccountUpdate(object sender, AccountUpdateEventArgs e) { Print(e.ItemType.ToString() + " " + e.Value); }
Comment
-
That is because your syntax for GetAccountValue() is incorrect. Here is an example of how to do it correctly.Originally posted by entropy View PostHi Jesse thanks for the pointer, it appears that the GetAccountValue method still won't compile in the indicator context. This code:
private void StoreAccountValue()
{
foreach (Account acct in Cbi.Globals.Accounts)
{
string acctvalstr = acct.GetAccountValue.ToString();
Print(acctvalstr);
}
}
generates: "method not valid in the given context" Works fine for acct.Name
Is there another way to access the account value using acct. ? Thanks!
Code:Print("Accounts Enumerated from 'for' loop"); for (int i = 0; i <= NinjaTrader.Cbi.Globals.Accounts.Count - 1; ++i) { Print(String.Format("{0}: {1}: {2}" , NinjaTrader.Cbi.Globals.Accounts[i].Name , NinjaTrader.Cbi.Globals.Accounts[i].GetAccountValue(AccountItem.CashValue, Currency.Unknown) , NinjaTrader.Cbi.Globals.Accounts[i].ToString())); }
Comment
Latest Posts
Collapse
| Topics | Statistics | Last Post | ||
|---|---|---|---|---|
|
Started by Geovanny Suaza, 02-11-2026, 06:32 PM
|
0 responses
574 views
0 likes
|
Last Post
|
||
|
Started by Geovanny Suaza, 02-11-2026, 05:51 PM
|
0 responses
333 views
1 like
|
Last Post
|
||
|
Started by Mindset, 02-09-2026, 11:44 AM
|
0 responses
101 views
0 likes
|
Last Post
by Mindset
02-09-2026, 11:44 AM
|
||
|
Started by Geovanny Suaza, 02-02-2026, 12:30 PM
|
0 responses
553 views
1 like
|
Last Post
|
||
|
Started by RFrosty, 01-28-2026, 06:49 PM
|
0 responses
551 views
1 like
|
Last Post
by RFrosty
01-28-2026, 06:49 PM
|

Comment