I am currently developing an addon for NinjaTrader and have encountered a question regarding the order lifecycle management, specifically related to the OnOrderUpdate event and order cancellation.
In my addon, I'm subscribing to the OnOrderUpdate event to handle order updates. I have logic in place to check certain conditions when an order is in the Initialized state. Based on these conditions, I may decide to cancel the order. My question is about the chronological order of events and the reliability of canceling an order during the OnOrderUpdate when it's in the Initialized state(if (e.Order.OrderState == OrderState.Initialized)):
- Chronological Order of Events: Is the OnOrderUpdate event guaranteed to trigger chronologically as per the order states transition? Specifically, can I always expect an order to trigger an OnOrderUpdate event with the Initialized state before any other state?
- Order Cancellation Timing: If the condition to cancel an order is met during the Initialized state within the OnOrderUpdate event, does this guarantee that the cancellation request will be processed before the order is sent to the broker? Or is there a risk that the order might still be sent out due to internal processing sequences or timing?
Understanding this behavior is crucial for the effective management of trading actions by the addon, especially in fast-moving markets. I appreciate any insights or guidance you can provide on these points to help ensure the addon behaves reliably under various market conditions.
Thank you in advance for your assistance.
Best regards,
Aviram Y.

Comment