Here is what I did:
(1) Manually submit a limited buy order through SuperDOM. This order is pending...
(2) Start Strategy() which includes the following code:
In OnStateChange():
Existing order can be found using
foreach (Order order in myAccount.Orders)
...
{
Print ("order =" + order); // it is confirmed this order is the correct pre-existing order
CancelOrder(order);
Print ("order =" + order); // nothing is printed here, so it looks like the order is canceled.
}
Later I can see this pre-existing order has not be cancelled. I also tried myCancelOrder = GetRealtimeOrder(order); it didn't work either. Adding the codes to OnBarUpdate() won't help.
Could you tell what I may have done incorrectly? What's the correct way to cancel this order?
Thanks in advance.
Comment