if (State == State.DataLoaded)
{
foreach (Order order in myAccount.Orders)
{
myAccount.CancelAllOrders(order.Instrument);
}
}
If I move the above code to under (State == State.SetDefaults), then it works fine. It can cancel all pending orders and start my strategy. But putting under SetDefaults, it is dangerous, because it can be triggered when I start any other Strategies.
Is there a way to do this under State.DataLoaded and still can enable Strategy?
Comment