Print("myEntryLong = " + myEntryLong);
if (myEntryLong != null && (myEntryLong.OrderState == OrderState.Working || myEntryLong.OrderState == OrderState.Accepted)) // Cancel previous stop order if it exists
{
Print(Instrument.MasterInstrument.Name + " - Canceling previous long stop order at " + myEntryLong.StopPrice);
CancelOrder(myEntryLong); // Cancel previous long stop order
Print(Instrument.MasterInstrument.Name + " " + myEntryLong.StopPrice + " cancelled.");
}
And in the OnOrderUpdate() tag I have this code:
Print(Instrument.MasterInstrument.Name + " - " + order.Name + " order " + order.OrderState);
if (order.OrderState == OrderState.Filled)
{
myEntryLong = null;
}
But (only sometimes!?) when this code executes, I get this error in the Log tab:
Cbi.Order.Cancel: exception caught: Value cannot be null.
Do you know what this error means, and how to debug it? I'm stumped, and I have the debug "Print" lines in there to try to help, but it's not helping.

Thanks!
Bryan

Comment