Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

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

Collapse
X
 
  • 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.

    #2
    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

    Comment


      #3
      Hi,

      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?

      Comment


        #4
        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

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by varsha, Today, 06:33 PM
        0 responses
        13 views
        0 likes
        Last Post varsha
        by varsha
         
        Started by NtFan, Today, 04:12 PM
        1 response
        8 views
        0 likes
        Last Post NtFan
        by NtFan
         
        Started by futurenow, Today, 01:44 PM
        2 responses
        38 views
        0 likes
        Last Post voltation  
        Started by Gerik, Today, 12:44 PM
        1 response
        15 views
        0 likes
        Last Post NinjaTrader_Jim  
        Started by autogenix, Today, 01:01 PM
        3 responses
        20 views
        0 likes
        Last Post NinjaTrader_Emily  
        Working...
        X