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 kevinenergy, 02-17-2023, 12:42 PM
        116 responses
        2,757 views
        1 like
        Last Post kevinenergy  
        Started by franatas, 12-04-2023, 03:43 AM
        7 responses
        106 views
        0 likes
        Last Post NinjaTrader_ChelseaB  
        Started by jpapa, Today, 07:22 AM
        0 responses
        1 view
        0 likes
        Last Post jpapa
        by jpapa
         
        Started by Jltarrau, Today, 05:57 AM
        3 responses
        7 views
        0 likes
        Last Post Jltarrau  
        Started by f.saeidi, Today, 05:56 AM
        2 responses
        8 views
        0 likes
        Last Post NinjaTrader_Erick  
        Working...
        X