ExecutionUpdate
Definition
ExecutionUpdate is used for subscribing to execution update events.
Remember to unsubscribe if you are no longer using the subscription.
Syntax
ExecutionUpdate
Examples
/* Example of subscribing/unsubscribing to execution update events from an Add On. The concept can be carried overto any NinjaScript object you may be working on. */public class MyAddOnTab : NTTabPage{private Account account;public MyAddOnTab(){// Find our Sim101 accountlock (Account.All)account = Account.All.FirstOrDefault(a => a.Name == "Sim101");// Subscribe to execution updatesif (account != null)account.ExecutionUpdate += OnExecutionUpdate;}/* This method is fired as new executions come in, an existing execution is amended(e.g. by the broker's back office), or an execution is removed (e.g. by the broker's back office) */private void OnExecutionUpdate(object sender, ExecutionEventArgs e){// Output the executionNinjaTrader.Code.Output.Process(string.Format("Instrument: {0} Quantity: {1} Price: {2}",e.Execution.Instrument.FullName, e.Quantity, e.Price), PrintTo.OutputTab1);}// Called by TabControl when tab is being removed or window is closedpublic override void Cleanup(){// Make sure to unsubscribe to the execution subscriptionif (account != null)account.ExecutionUpdate -= OnExecutionUpdate;}// Other required NTTabPage members left out for demonstration purposes. Be sure to add them in your own code.}