AccountStatusUpdate

View as Markdown

Definition

AccountStatusUpdate can be used for subscribing to account status events from all accounts.

Remember to unsubscribe if you are no longer using the subscription.

Syntax

AccountStatusUpdate

Examples

1/* Example of subscribing/unsubscribing to account status update events from an Add On. The concept can be carried over
2to any NinjaScript object you may be working on. */
3public class MyAddOnTab : NTTabPage
4{
5 public MyAddOnTab()
6 {
7 // Subscribe to account status updates
8 Account.AccountStatusUpdate += OnAccountStatusUpdate;
9 }
10
11 // This method is fired on any status change of any account
12 private void OnAccountStatusUpdate(object sender, AccountStatusEventArgs e)
13 {
14 // Output the account name and status
15 NinjaTrader.Code.Output.Process(string.Format("Account: {0} Status: {1}",
16 e.Account.Name, e.Status), PrintTo.OutputTab1);
17 }
18
19 // Called by TabControl when tab is being removed or window is closed
20 public override void Cleanup()
21 {
22 // Make sure to unsubscribe to the account status subscription
23 Account.AccountStatusUpdate -= OnAccountStatusUpdate;
24 }
25
26 // Other required NTTabPage members left out for demonstration purposes. Be sure to add them in your own code.
27}