Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

OrderState.Unknown vs Order.IsTerminalState

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

    OrderState.Unknown vs Order.IsTerminalState

    The NT8 Help describes OrderState.Unknown as "An unknown order state. Default if broker does not report current order state.".

    Order.IsTerminalState is described as "A static method used to determine if the an order's OrderState is considered terminal and no longer active." and includes OrderState.Unknown in its determination.

    If the OrderState of an Order is OrderState.Unknown because the broker has not returned the OrderState, isn't it true that the Order could, in fact, still be "active", but not reported by the broker as such?

    If this is so, isn't declaring the Order (from its OrderState using Order.IsTerminalState) as "no longer active" inaccurate, at best? And doesn't it risk the Order consequentially being ignored and left "active" and therefore completely unmanaged by the trader, when in fact, it may be active and in loss (for example)?

    Thanks.
    Multi-Dimensional Managed Trading
    jeronymite
    NinjaTrader Ecosystem Vendor - Mizpah Software

    #2
    Hello jeronymite,

    Unfortunately I don't have any specifics that I could provide detailing into how the IsTerminalState bool specifically becomes true in that situation. If you are currently seeing unknown state orders from a specific broker where the IsTermalState is true but the order remains open we could review that situation further and pass along the details to development. Because the unknown state happens for unknown order reasons I could only speculate that it may be possible that the order was still open but NinjaTrader is now unaware due to the connection providing an unknown state. Generally in that situation you would want to contact the broker to verify the account is flat and orders are managed.

    Please let me know if I may be of further assistance.

    Comment


      #3
      Thanks, Jesse.

      This is a theoretical question -- I do not have any direct experience with Orders in OrderState.Unknown. It is the documented behaviour that I want to take into account as I write a large AddOn for commercial distribution.

      The Help says that Order.IsTerminalState is a "bool value which will return true when an OrderState is equal to OrderState.Cancelled, OrderState.Filled, OrderState.Rejected, OrderState.Unknown; otherwise false.". Given the Help for OrderState.Unknown says it is the "Default if broker does not report current order state", I would query if including OrderState.Unknown in the test for Order.IsTerminalState makes sense. Since, by definition, the Order state is unknown, it could just as easily be "alive and active" as "terminal and no longer active".

      To presume an unknown Order state is "terminal and no longer active" would seem to be the least desirable approach, since the possibility of it remaining alive and active is just as real as not. My own view would be that the state should not be included in the Order.IsTerminalState determination, and it should be documented along the lines of "test again as soon as possible, and if still unknown, contact the broker as the Order may be alive and active".

      I would recommend reconsidering how this all works to try to ensure that if a broker does not return information, the more conservative and cautious approach is taken, rather than assuming the Order is "all good because it's terminated". Of course, I can take this approach in my own code, but a more responsible approach is, I think, to reconsider how it works for all NT users.

      Thanks.
      Multi-Dimensional Managed Trading
      jeronymite
      NinjaTrader Ecosystem Vendor - Mizpah Software

      Comment


        #4
        Hello jeronymite,

        Unless you are seeing that specifically come up as a situation I would not suggest to try and peruse adding handling for that case. You could potentially log it in case this is a script that is used across multiple connections to see if any user ever hits an unknown state order. That is mostly just a catch all for unknown or unmapped responses for the order state. Unfortunately I couldn't provide much guidance beyond that in regard to that state.



        Please let me know if I may be of further assistance.

        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