I was using this IOrder output as a unique marker for each trade. Perhaps this was a mistake.
As I step through the debugger, I notice that often IOrder returns null. Such as in OnOrderUpdate (or the same is in OnExecution):
IOrder myOrder = ExitLongStop(0,true,quantityInt,stopPrice,exitName,enterName);
Looking through other forum help about the subject, it seems that the explanation is that filling the IOrder to a non-null value may happen in a different thread, and thus, myOrder may become non-null later.
The problem is that I want to know myOrder so that I can place it in my custom order object and move on.
The question is: If the IOrder cannot be guaranteed to be written at the time the order is called, how can I use it? Must I declare IOrder myOrder as a global in the strategy? If the IOrder output is not written immediately afterward, then it makes no sense to declare IOrder myOrder locally in OnOrderUpdate or OnExecution. Is this correct? Am I going to need to create my own order fingerprint, and forget using an IOrder object?
Has anyone run into similar problems? Suggestions? Thanks.
Comment