Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
How to Subscribe to OnOrderUpdates
Collapse
X
-
How to Subscribe to OnOrderUpdates
In the supplied Strategy SimpleMACrossover, there is a drop-down in properties for the desired account. How do I get access to the variable to assign it to an Account object to use it to subscribe to OnOrderUpdate.? Thank You. This should be Strategies, sorry.Last edited by kenz987; 02-22-2023, 09:58 PM.Tags: None
-
The data you want is already provided.
The name of the variable is (not surprisingly) Account.
A strategy object's OnOrderUpdate is already 'subscribed' to
what the Account object's OrderUpdate callback would see.
What are you trying to achieve?Last edited by bltdavid; 02-23-2023, 06:43 AM.
-
Hello kenz987,
Thanks for your post.
bltdavid is correct. Please see the Account documentation linked below demonstrating how the Account class could be used.
Account: https://ninjatrader.com/support/help...ount_class.htm
If you are referring to subscribing an Account to OrderUpdate events, see the help guide documentation below for information and sample code.
OrderUpdate: https://ninjatrader.com/support/help...rderupdate.htm
Please let me know if I you have further questions.<span class="name">Brandon H.</span><span class="title">NinjaTrader Customer Service</span><iframe name="sig" id="sigFrame" src="/support/forum/core/clientscript/Signature/signature.php" frameborder="0" border="0" cellspacing="0" style="border-style: none;width: 100%; height: 120px;"></iframe>
Comment
-
Then what is the purpose of all this:
private Account account;
lock (Account.All)
account = Account.All.FirstOrDefault(a => a.Name == "Sim101");
You show how to make sure you are on the Sim account, but nothing for the Live account. Its very confusing.
Comment
-
Hello kenz987,
Thanks for your note.
If the strategy runs on your Live account, you could simply use Account and the OnOrderUpdate() method as bltdavid stated to get Account information about the account or OnOrderUpdate information in the strategy.
Account: https://ninjatrader.com/support/help...gy_account.htm
OnOrderUpdate: https://ninjatrader.com/support/help...rderupdate.htm
To get information about a specific account, you could assign the account to an Account variable and subscribe to OrderUpdate events. The sample code in the Account help guide page in post # 3 simply demonstrates how you could find a specific account based on the account name and assign it to an Account variable.
You could apply this concept to your script but use your Live account name instead of "Sim101" if you want to assign your Live account to an Account variable.
Please let me know if I may assist further.<span class="name">Brandon H.</span><span class="title">NinjaTrader Customer Service</span><iframe name="sig" id="sigFrame" src="/support/forum/core/clientscript/Signature/signature.php" frameborder="0" border="0" cellspacing="0" style="border-style: none;width: 100%; height: 120px;"></iframe>
Comment
-
OK But that means changing code and re-compiling all the time. Ok Thanks on that.
Another question: When I run this I get numerous old accounts, they still say Enabled,
They just waste space and are of no use, can I delete them? How?
foreach (Account sampleAccount in Account.All)
Print(String.Format("The account {0} has a {1} unit FX lotsize set", sampleAccount.Name, sampleAccount.ForexLotSize));
Comment
-
Hello kenz987,
Thanks for your note.
The code you shared would be looping through all accounts that are on your platform. There is no supported/documented way to programmatically delete an account.
You could consider writing in to support[AT]ninjatrader.com to request an account be removed or disabled.
What exactly are you trying to accomplish so I may accurately assist?
Are you wanting to print out the account information for the account that a strategy is running on?
If so, you would just call Account.Name or Account.ForexLotSize without looping through each account in Account.All.
Do you want to print out information about a specific account?
If so, you would need to assign that specific account to an Account variable as seen in the sample code of the Account help guide linked in post # 3.
For example, the sample code assigns the Sim101 account to an Account variable named something like 'account'. Then, you could access information about that specific account by calling something like account.Name or account.ForexLotSize.
Let me know if I may assist further.<span class="name">Brandon H.</span><span class="title">NinjaTrader Customer Service</span><iframe name="sig" id="sigFrame" src="/support/forum/core/clientscript/Signature/signature.php" frameborder="0" border="0" cellspacing="0" style="border-style: none;width: 100%; height: 120px;"></iframe>
Comment
Latest Posts
Collapse
| Topics | Statistics | Last Post | ||
|---|---|---|---|---|
|
Started by Geovanny Suaza, 02-11-2026, 06:32 PM
|
0 responses
648 views
0 likes
|
Last Post
|
||
|
Started by Geovanny Suaza, 02-11-2026, 05:51 PM
|
0 responses
369 views
1 like
|
Last Post
|
||
|
Started by Mindset, 02-09-2026, 11:44 AM
|
0 responses
109 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
573 views
1 like
|
Last Post
|
||
|
Started by RFrosty, 01-28-2026, 06:49 PM
|
0 responses
575 views
1 like
|
Last Post
by RFrosty
01-28-2026, 06:49 PM
|

Comment