CancelAllOrders()

View as Markdown

Definition

Cancels all Order of an instrument.

Syntax

CancelAllOrders(Instrument instrument)

Parameters

ParameterDescription
instrumentInstrument of the orders to be cancelled

Example

1private Account myAccount;
2
3protected override void OnStateChange()
4{
5 if (State == State.SetDefaults)
6 {
7 // Initialize myAccount
8 }
9}
10
11private void OnExecutionUpdate(object sender, ExecutionEventArgs e)
12{
13 // Cancel all orders if an execution is triggered after 9pm
14 if (e.Time > new DateTime(now.Year, now.Month, now.Day, 21, 0, 0))
15 myAccount.CancelAllOrders(e.Execution.Instrument);
16}