Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

StopLoss didn't cancel within seconds of the canceled, resulted in a reverse.

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

    StopLoss didn't cancel within seconds of the canceled, resulted in a reverse.

    I had a live scenario whereby I had an order at the exchange with an OCO in effect (profit and stop). The market dropped and my system issued an ExitLong with the tag name. It executed correctly but the Stop Loss triggered 3 secs later resulting in a reverse essentially. According to the docs, this is not supposed to be able to happen.

    Assuming this happens, how can I trap this to protect my strategies in the future? Any suggestions would be appreciated.

    D.


    #2
    Originally posted by MarketAlly View Post
    The market dropped and my system issued an ExitLong with the tag name. It executed correctly but the Stop Loss triggered 3 secs later resulting in a reverse essentially.
    I reviewed the logs and actually it happened at the same time - I sent them to support but apart from tracking this in the OnExecution - I am unsure how to protect myself from something that in essense - imo - is a failure of the exchange. Since the exit would have the same tag unless NT8 doesn't send a order like that.

    Comment


      #3
      Hello MarketAlly,

      Is the stop loss submitted with SetStopLoss()?

      Or are you using ExitLongStopMarket() / ExitShortStopMarket()?

      Either way, the oco only works with orders that have the same OCO ID. Your market order should not have an OCO ID (because its a market order) and thus no other orders will be cancelled when that market order fills.

      However, when using 'from entry signal' names matching the entry order's signal name, the exit order should have a cancellation request sent when the position created by the entry order is closed. (This would be subject to in-flight-executions and could result in an overfill)
      Chelsea B.NinjaTrader Customer Service

      Comment


        #4
        Originally posted by NinjaTrader_ChelseaB View Post
        Hello MarketAlly,

        Is the stop loss submitted with SetStopLoss()?

        Or are you using ExitLongStopMarket() / ExitShortStopMarket()?

        Either way, the oco only works with orders that have the same OCO ID. Your market order should not have an OCO ID (because its a market order) and thus no other orders will be cancelled when that market order fills.

        However, when using 'from entry signal' names matching the entry order's signal name, the exit order should have a cancellation request sent when the position created by the entry order is closed. (This would be subject to in-flight-executions and could result in an overfill)
        Yes - set via SetStopLoss.

        I used ExitLong with the same formSingalName

        The exit order did not cancel the stop in time, and resulted in two transactions as seen in the logs. I am unsure how to resolve this. I want the most robust method but at some level feel NT8 should be able to detect this and close the order rather than me trapping it.

        Comment


          #5
          Originally posted by NinjaTrader_ChelseaB View Post
          (This would be subject to in-flight-executions and could result in an overfill)
          And if you are wondering... this happened on 5 client machines running my strategies - this was not a one-off instance.

          Comment


            #6
            Hello MarketAlly,

            There won't be any OCO between your market exit and the stop loss placed with set stop loss.

            NinjaTrader will automatically send a cancellation for the stop loss, however until that cancellation is received and filled, its still possible for the stop loss to fill.

            If you want to guarantee that both orders don't fill, then use an ExitLongStopMarket() / ExitShortStopMarket instead of using SetStopLoss() and in OnOrderUpdate() assign the order object to an Order variable. Then when you want to exit, call CancelOrder() with the variable of the working stop market and in OnOrderUpdate when the stop market is fully cancelled then submit the ExitLong() / ExitShort() market order.
            Chelsea B.NinjaTrader Customer Service

            Comment


              #7
              I am not sure you are understanding the workflow.

              1. my system entered the market EnterLong with fromSignalName
              2. it issued a OCO with SetStopLoss and SetProfitTarget using fromSignalName

              Everything is correctly working

              ** market falls **

              3. Market action causes strategy to exit via ExitLong using same fromSignalName
              ** this should cancel the OCO **

              4. Market triggers Stop in OCO same time from a fast moving market.
              5. Log shows two transactions different orderId for same fromSignalName

              I am trapping this now and shutting the strategy down in the case of a mismatch quantity for the above scenario which I log on my end - but this is the 2nd issue I have encountered

              #disappointed.
              Last edited by MarketAlly; 10-24-2018, 11:29 AM.

              Comment


                #8
                Originally posted by NinjaTrader_ChelseaB View Post
                Then when you want to exit, call CancelOrder() with the variable of the working stop market and in OnOrderUpdate when the stop market is fully cancelled then submit the ExitLong() / ExitShort() market order.
                You do realize that scenario places me and my clients in the most harm should the market have a waterfall event as futures often do on the charts. What NT should do, is handle this when developers use the fromSignalName since you are in the best position to detect and resolve such incidents. If it results in slippage, that is fine but "managed" orders should be exactly that.

                Comment


                  #9
                  Hello MarketAlly,

                  Placing a second exit while another exit order is already working can result in both orders filling.
                  Because NinjaTrader has to communicate through the internet to send that cancellation there is no way for NinjaTrader to guarantee that order will be cancelled instead of filled.

                  If you want a guarantee, then I would advise using the steps I have outlined by cancelling the working order first and when the cancellation is successful then placing the other order.

                  That said, if you want me to create an example for you that shows exiting a position will cause any stop loss attached to that position to automatically get a cancellation request I am happy to make a test script to demonstrate this for you. This still won't guarantee that the stop loss is cancelled though. It will just show that NinjaTrader will attempt to cancel it.

                  Chelsea B.NinjaTrader Customer Service

                  Comment


                    #10
                    I'm having the same issues with my strategy.
                    Detailed here: https://ninjatrader.com/support/foru...t-order-oco-id

                    It is happening a lot for me (several times per day). I just need to watch closely and intervene when this happens.

                    This is a serious oversight in the design of the managed strategy system in my opinion. The "Exit Long" and "Exit Short" market orders are submitted WITHOUT an OCO ID. If they used an OCO ID then the Exit market order would then get cancelled immediately upon submission if the stop order had already triggered. There's no need for these to be cancelled manually - they cancel each other - that's the point of OCO.

                    This is a BIG PROBLEM with the Ninjatrader Managed Order API. It is not how things are supposed to work and exposes us to a huge amount of risk. My strategy ends up opening an unprotected position and doesn't take any more trades.

                    Comment


                      #11
                      kevinenergy


                      I had taken this offline since they were reviewing my logs and while I agree with you - it appears the documents are somewhat misleading around the actual way I perceived it was working and what is actually happening.

                      To summarize, When I call SetProfitTarget with MIT as false, this places a limit order at the exchange but with MIT it is essentially a simulated order or so it has been communicated to me. Where the use of simulated around setSellStop is clear in the docs, the use of MIT on setProfitTarget is where the disconnect is. Despite the docs saying "Profit target orders are real working orders submitted immediately to the market upon receiving an execution from an entry order."

                      https://ninjatrader.com/support/helpGuides/nt8/en-us/setprofittarget.htm

                      So in my workflow when I get execution of the initial entry, I set the SetSellStop immediately with the fromSignalName. I am waiting to hear if I am supposed to then also call the ExitLongStopMarket with the fromSignalName at the same time instead of the setProfitTarget. This will place both orders at the exchange as an OCO and will cancel in the event either side is hit albeit I am not sure but I am inclined to use the setProfitTarget with MIT as false and place it one tick below my target to get my same desired effect since it must fill to have a tick at my target.

                      It also makes sense when I have seen in my charting app the target get hit but my MIT target not execute on really fast moves.

                      Comment


                        #12
                        Originally posted by kevinenergy View Post
                        I'm having the same issues with my strategy.
                        Detailed here: https://ninjatrader.com/support/foru...t-order-oco-id
                        This means it is not really an OCO - so when I EnterLong - like you do in your thread, it is not canceling the Stop order. It must be canceled on NT's side very quickly but it is technically not at the exchange. Hence the issue we see since it is an open leg for the Stop order and why I feel a "managed" order should handle the slippage around this scenario but my experience is to workaround not wait for them to resolve.. And the documentation, something that is not communicated to a satisfactory level imo.

                        And further complicated that the backtesting, sim and playback work as we assume it to be vs a live order.
                        Last edited by MarketAlly; 10-24-2018, 10:07 PM.

                        Comment


                          #13
                          As far as I understand it, MIT orders are executed from your computer. For a Long MIT Target, when Ninjatrader sees the bid trade equal to the target price it submits a market order.

                          Your description in Post #1 is exactly the issue I'm having (Exit@Market and stop being executed simultaneously) - I'm not sure where MIT comes into it.

                          Comment


                            #14
                            Hello MarketAlly,

                            The link you have provided is to the ExitLongStopMarket() page of the help guide.

                            Were you meaning to link to link the Simulated Stop Order section of the help guide? (MIT orders are similar to simulated stop orders)
                            https://ninjatrader.com/support/help...top_orders.htm

                            Is your script using a Market If Touched order? If so, these orders are not submitted until they are touched and the OCO does not become effective until the order is submitted.
                            Chelsea B.NinjaTrader Customer Service

                            Comment


                              #15
                              Originally posted by NinjaTrader_ChelseaB View Post
                              The link you have provided is to the ExitLongStopMarket() page of the help guide.

                              Were you meaning to link to link the Simulated Stop Order section of the help guide?
                              Sorry copying url in frame doesn't relate - I was referring to the SetProfitTarget page.

                              Originally posted by NinjaTrader_ChelseaB View Post
                              Is your script using a Market If Touched order? If so, these orders are not submitted until they are touched and the OCO does not become effective until the order is submitted.
                              That is not always true - meaning I have seen the target hit and the order not convert (rare but does occur) BUT now I understand these are not valid OCOs at the exchange which is "not" clear in the docs and it is very important. Please don't tell me the ExitLong/ExitShort with the same fromSignalName doesn't cancel like the docs say it will - I have tested and it is does but to kevinenergy point - in the case I outlined - it will not work correctly from what I am assuming is a race state around the app canceling vs an actual OCO at the exchange as you outlined. And by the way, regardless what your dev team says - is a BUG for "managed" orders. Unmanaged we can agree but not managed.

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by argusthome, 03-08-2026, 10:06 AM
                              0 responses
                              80 views
                              0 likes
                              Last Post argusthome  
                              Started by NabilKhattabi, 03-06-2026, 11:18 AM
                              0 responses
                              46 views
                              0 likes
                              Last Post NabilKhattabi  
                              Started by Deep42, 03-06-2026, 12:28 AM
                              0 responses
                              29 views
                              0 likes
                              Last Post Deep42
                              by Deep42
                               
                              Started by TheRealMorford, 03-05-2026, 06:15 PM
                              0 responses
                              32 views
                              0 likes
                              Last Post TheRealMorford  
                              Started by Mindset, 02-28-2026, 06:16 AM
                              0 responses
                              66 views
                              0 likes
                              Last Post Mindset
                              by Mindset
                               
                              Working...
                              X