Cancel()

View as Markdown

Definition

Cancels specified Order object(s).

Syntax

Cancel(IEnumerable\<order\> orders)

Parameters

ParameterDescription
ordersOrder(s) to cancel

Examples

1private Account myAccount;
2Order stopOrder = null;
3
4protected override void OnStateChange()
5{
6 if (State == State.SetDefaults)
7 {
8 // Initialize myAccount
9 }
10}
11
12private void OnExecutionUpdate(object sender, ExecutionEventArgs e)
13{
14 // Cancel the stop order if an execution results in a long position
15 if(e.MarketPosition == MarketPosition.Long)
16 myAccount.Cancel(new[] { stopOrder });
17}