So how can I detect exactly this error. Yes I know that I can set RealtimeErrorHandling.StopCancelCloseIgnoreRejects and catch this error in OnOrderUpdate. But when I have that order, what is the best way to check to see the the rejection was for that reason?
I see that there is a comment field in OnOrderUpdate, and that comment will contain the error message from the broker. However, this message is from the broker, so it is not standardized, and I don't know the exact wording. Is there any list anywhere of the exact wording of error messages from Ninjatrader/Dorman broker?
If I can't use the error message, then I thought maybe I could save all the orders in Order variables in the strategy and I could check to see if the corresponding target order has been filled. But is it possible in a fast moving market for the target to get filled and the corresponding stop gets rejected before the platform calls OnOrderUpdate for the target? In other words, is this sequence possible in a fast market:
1. Stop and target orders submitted
2. OnOrderUpdate called for target because order accepted
3. target order gets filled but OnOrderUpdate is not called yet.
4. OnOrderUpdate gets called because stoploss gets rejected.
I also know that I can use a timer and delayed event to wait a second before checking to see if OnOrderUpdate has been called with the target being filled. But this is not very satisfying, it gives an extra second for the strategy to have no stoploss if there is a strong adverse move.
So ideally, I want to know at the point where OnOrderUpdate is called for a rejected stop, what exactly the reason is at that moment in a way that I can act on it.
How can I do this?
Comment