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!
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
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.JesseNinjaTrader Customer Service
-
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.
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); }
JesseNinjaTrader Customer Service
Comment
-
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 inanazsocial, Today, 01:15 AM
|
0 responses
1 view
0 likes
|
Last Post
by inanazsocial
Today, 01:15 AM
|
||
Started by trilliantrader, 04-18-2024, 08:16 AM
|
5 responses
22 views
0 likes
|
Last Post Today, 12:32 AM | ||
Started by Davidtowleii, Today, 12:15 AM
|
0 responses
3 views
0 likes
|
Last Post
by Davidtowleii
Today, 12:15 AM
|
||
Started by guillembm, Yesterday, 11:25 AM
|
2 responses
9 views
0 likes
|
Last Post
by guillembm
Yesterday, 11:58 PM
|
||
Started by junkone, 04-21-2024, 07:17 AM
|
9 responses
70 views
0 likes
|
Last Post
by jeronymite
Yesterday, 11:51 PM
|
Comment