Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

OrderState.Working

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

    OrderState.Working

    Ref: "Critical: In a historical backtest, orders will always reach a "Working" state. In real-time, some stop orders may only reach "Accepted" state if they are simulated/held on a brokers server"

    on this: https://ninjatrader.com/support/help...injascript.htm

    If I want to only ChangeOrder when OrderState.Working what's the best way to code this?​

    #2
    Hello dibDab,

    Thanks for your post.

    OnOrderUpdate() could be used to track order objects and get the OrderState of an order. You could consider tracking your order objects in OnOrderUpdate() and calling the CancelOrder() method when the OrderState of the order is equal to OrderState.Working.

    See the help guide documentation below for more information and sample code.

    OnOrderUpdate(): https://ninjatrader.com/support/help...rderupdate.htm
    SampleOnOrderUpdate: https://ninjatrader.com/support/help...and_onexec.htm

    Let me know if I may assist further.
    <span class="name">Brandon H.</span><span class="title">NinjaTrader Customer Service</span><iframe name="sig" id="sigFrame" src="/support/forum/core/clientscript/Signature/signature.php" frameborder="0" border="0" cellspacing="0" style="border-style: none;width: 100%; height: 120px;"></iframe>

    Comment


      #3
      Ref: "Critical: In a historical backtest, orders will always reach a "Working" state. In real-time, some stop orders may only reach "Accepted" state if they are simulated/held on a brokers server"

      is this ok?

      if (myOrder != null && (myOrder.OrderState == OrderState.Working || myOrder.OrderState == OrderState.Accepted)

      Comment


        #4
        Hello dibDab,

        Thanks for your note.

        Yes, this could be the correct use of checking for the OrderState of an order object. The code you shared would check if myOrder is not null and if the OrderState of myOrder is OrderState.Working or OrderState.Accepted.

        Let me know if I may further assist.
        <span class="name">Brandon H.</span><span class="title">NinjaTrader Customer Service</span><iframe name="sig" id="sigFrame" src="/support/forum/core/clientscript/Signature/signature.php" frameborder="0" border="0" cellspacing="0" style="border-style: none;width: 100%; height: 120px;"></iframe>

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by NullPointStrategies, Yesterday, 05:17 AM
        0 responses
        62 views
        0 likes
        Last Post NullPointStrategies  
        Started by argusthome, 03-08-2026, 10:06 AM
        0 responses
        134 views
        0 likes
        Last Post argusthome  
        Started by NabilKhattabi, 03-06-2026, 11:18 AM
        0 responses
        75 views
        0 likes
        Last Post NabilKhattabi  
        Started by Deep42, 03-06-2026, 12:28 AM
        0 responses
        45 views
        0 likes
        Last Post Deep42
        by Deep42
         
        Started by TheRealMorford, 03-05-2026, 06:15 PM
        0 responses
        50 views
        0 likes
        Last Post TheRealMorford  
        Working...
        X