No announcement yet.

Partner 728x90


SL or TP orders stay on State 'ChangePending', how to resolve this?

  • Filter
  • Time
  • Show
Clear All
new posts

    SL or TP orders stay on State 'ChangePending', how to resolve this?

    Sometimes after adjusting an SL or TP order in the SIM account, it stays on 'ChangePending' and nothing happens anymore.
    If I try to adjust it again by manually dragging it in the chart, it just snaps back to the previous position.
    Even after quitting and restarting Ninjatrader the order is still 'Change Pending' and I cannot do anything to cancel or adjust it (only resetting the SIM account helps).

    How does this happen (in SIM account!) and what can I do to fix such an order once it's on 'Change Pending'?
    Obviously I don't want to reset my SIM account every time.

    PS: it happens sometimes once or twice a day and sometimes it doesn't happen for a few days (which means it happens about 10% or so of all trades).
    The order and its SL and TP orders are submitted manually in an indicator with account.submit(), and the SL and TP orders are adjusted with account.change().
    Since this works fine (except sometimes as described above) I suppose it's not an indicator issue.

    Hello wjadevries,

    Thanks for your post.

    Simulation orders can get stuck when the simulation engine gets jammed. This is often seen when there are numerous changes to an order, or numerous cancels submitted to an order that are made in rapid succession.

    Resetting the Sim account will get the stuck orders cleared, but I would suggest looking into your order changing logic to ensure changes are not happening too frequently. For example, if the script is updating orders OnEachTick, try using Calculate.OnPriceChange, or incorporate logic to prevent submissions until a small amount of time has passed from the last change.

    I have attached an indicator that demonstrates adding a timer for a "delayed event." This could be used to flip a bool that allows order changes to prevent them from being placed too quickly.

    We look forward to assisting.
    Attached Files
    JimNinjaTrader Customer Service



      I already implemted such a delayed timer for order updates, but it doesn't help.
      Sometimes order changes are handled without any issues, and sometimes the whole Ninjatrader application hangs.
      When I restart it, there's always a 'Changes pending' order which I can only get rid of by resetting the SIM account.
      Any further suggestions?


        Hello wjadevries,

        I suggest commenting out code until the hanging issue goes away and then uncomment code to identify the specific part that is causing the platform to hang. Once you are left with a small testable example, please share it here and provide steps to reproduce so we may comment.

        With regards to delaying order updates, are you delaying everything in OnOrderUpdate, or are you using a timer to prevent frequent change orders when a change has already been made? The goal would be to limit how often your code can change orders/attempt to cancel them.

        Have you confirmed with prints how often order changes are made?

        When you add a print in OnOrderUpdate, can you confirm if order changes are happening frequently or cancellations are submitted frequently? If you can confirm this, this would be the behavior that needs to be limited.

        I look forward to assisting.
        JimNinjaTrader Customer Service


        Latest Posts


        Topics Statistics Last Post
        Started by punkiy2111, Today, 05:22 PM
        0 responses
        Last Post punkiy2111  
        Started by secrettrader, Today, 03:36 PM
        0 responses
        Last Post secrettrader  
        Started by t3chn0, Today, 01:03 PM
        1 response
        Last Post NinjaTrader_ChrisL  
        Started by jleira, Today, 02:27 PM
        0 responses
        Last Post jleira
        by jleira
        Started by Kreyenhagen, Today, 01:54 PM
        2 responses
        Last Post Kreyenhagen