Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

OnOrderUpdate Event Chronology and Order Cancellation Timing in Addon Development

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    OnOrderUpdate Event Chronology and Order Cancellation Timing in Addon Development

    Hello NinjaTrader Support and Community,

    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)):
    1. 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?
    2. 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.
    Aviram Y
    NinjaTrader Ecosystem Vendor - Aviram Y

    #2
    Hello Aviram Y,

    "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?"

    Yes, an order will always be State.Initialized before State.Submitted. However, the execution update, order update, and position update sequence may not be guaranteed depending on the broker.
    Hello, I see in the documentation you have fixed: 15048 Added Adapter, Rithmic Updated Rithmic API to version 11.3.0.0 Can you elaborate on that please? Will OnOrderUpdate() OnExecutionUpdate() and OnPositionUpdate() be called in the expected order?


    "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?"

    No, there is no guarantee the order will be cancelled before it is submitted.
    Order types like Market-If-Touched (MIT) would be created in the initialized state and would not change to the Submitted state until touched, and these can still be cancelled.
    It's not likely any other order type would be in the Initialized state long enough to cancel it before it is submitted. This a fraction of a second. Unless the order gets stuck and unable to submit it's most likely going to be submitted before your cancellation request is processed. If the order is stuck and is orange on the Orders tab of the Control Center it may not be possible to cancel. Disconnecting from the connection and re-connecting will clear the stuck order on a live account, resetting the Sim101 will clear the stuck order on the Sim101.

    That said, attempting to cancel an order that's in State.Initialize just before it's submitted (that is not an MIT order) doesn't make much sense. It would make more sense to not send the order.
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Originally posted by NinjaTrader_ChelseaB View Post
      That said, attempting to cancel an order that's in State.Initialize just before it's submitted (that is not an MIT order) doesn't make much sense. It would make more sense to not send the order.
      I see, this implementation is meant to be a fallback behavior in case some edge case using event handling for charts and other trading options fail to subscribe somehow. this clears things up! thank you.
      Best, Aviram Y.​
      Aviram Y
      NinjaTrader Ecosystem Vendor - Aviram Y

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by Geovanny Suaza, 02-11-2026, 06:32 PM
      0 responses
      633 views
      0 likes
      Last Post Geovanny Suaza  
      Started by Geovanny Suaza, 02-11-2026, 05:51 PM
      0 responses
      364 views
      1 like
      Last Post Geovanny Suaza  
      Started by Mindset, 02-09-2026, 11:44 AM
      0 responses
      105 views
      0 likes
      Last Post Mindset
      by Mindset
       
      Started by Geovanny Suaza, 02-02-2026, 12:30 PM
      0 responses
      567 views
      1 like
      Last Post Geovanny Suaza  
      Started by RFrosty, 01-28-2026, 06:49 PM
      0 responses
      568 views
      1 like
      Last Post RFrosty
      by RFrosty
       
      Working...
      X