Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

When stop orders turn to limit orders

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

    When stop orders turn to limit orders

    I have a strategy that places orders like this:

    entryOrder = EnterLongStopLimit(0, true, positionQuantity, entryPrice, entryPrice, "Long Order 1");

    This places a buy stop order above the market price. Sometimes the market will 'skip' this order and jump over that entry price above the stop order. At this point, somehow this stop order automatically changes to a limit order.

    I would like to either cancel the order immediately if skipped, or wait for x seconds or x ticks of movement before cancelling the order. Can you point me to the proper methods to override so I know when stop order has been skipped and changes to a limit order?

    Thanks!
    Bryan

    #2
    Bryan,

    Thank you for your post.

    There are couple things here that you can check.

    The first is if the price has moved above or below what you set the Stop price as.

    You can also check if the order has gone from Accepted to Working state since this would indicate that the stop price was hit and the Limit order is working.

    If the top is true and the second not, then we know that the price shot above the Stop price and our limit order is not working, you can then use CancelOrder() for entryOrder.

    Let me know if I can be of further assistance.
    Cal H.NinjaTrader Customer Service

    Comment


      #3
      Thank you, Cal. So there really is not a method or a flag in something like OnExecution or OnOrderUpdate or OnPositionUpdate that I can know immediately that a stop order was skipped so that I can cancel it right in that event? I need to check on every tick whether the Close[0] has passed my stop price and see if the order is still Working or Accepted?

      Also, is it normal for a stop limit order to change to a limit order if the stop price is skipped? Or is there a setting where I can auto-cancel the order if this happens?

      Thanks!
      Bryan

      Comment


        #4
        Bryan,

        Yes, this is expected to happen with Stop orders. Once the price has hit or passed the Stop price, it will start working for the limit, or market, order.

        Additionally, you can check the OnOrderUpdate() when the order changes its state from Accepted to Working and compare the Close[0] price at that point to the orders price.
        Cal H.NinjaTrader Customer Service

        Comment


          #5
          OK, thank you Cal. That helps me a lot. :-)

          Comment


            #6
            One more question, Cal. In another strategy I am using ATM strategies to manage the trade. So will GetAtmStrategyEntryOrderStatus() also give me the "Working" status and the entry price so I can check if that stop limit order was skipped?
            Last edited by cassb; 04-09-2015, 05:53 PM.

            Comment


              #7
              This is the definition of Stop Limit orders:

              DEFINITION of 'Stop-Limit Order'

              An order placed with a broker that combines the features of stop order with those of a limit order. A stop-limit order will be executed at a specified price (or better) after a given stop price has been reached. Once the stop price is reached, the stop-limit order becomes a limit order to buy (or sell) at the limit price or better.
              Ref: http://www.investopedia.com/terms/s/stop-limitorder.asp

              This order type is not familiar to (or not clearly understood) by many people, especially those who trade forex because it is not available in most forex trading platforms (including me before ).

              Pi
              ninZa
              NinjaTrader Ecosystem Vendor - ninZa.co

              Comment


                #8
                Yes, thank you ninZa. I was confused about it as well. I never understood how a stop limit order could be "skipped" before... but I guess it there are no opposing orders at your limit price, then you don't get filled but your order stays active.

                The problem with this order type happens when you are trying to catch a momentum surge at a specific price. If your order is not filled, many time you will want to cancel that order immediately because you missed the surge. This is what I'd like to write into my code.

                Cal, do you have an answer regarding using the ATMStrategyCreate method for this situation?

                Thanks!

                Comment


                  #9
                  Cassb,

                  Yes, that will work for this scenario.
                  Cal H.NinjaTrader Customer Service

                  Comment


                    #10
                    Originally posted by NinjaTrader_Cal View Post
                    Cassb,

                    Yes, that will work for this scenario.
                    OK, but what is the syntax of the command to catch the event when the order changes from Stop Limit to Limit and the order state is still Working and not Filled? Would that also be in OnOrderUpdate when you are using ATM strategies to manage the order?

                    Comment


                      #11
                      Bryan,

                      The help guide states that you need to use the [2] index of the string array that you are creating. The link below on GetAtmStrategyEntryOrderStatus() shows how to do this -
                      http://www.ninjatrader.com/support/h...rderstatus.htm

                      You can use any method to call the GetAtmStrategyEntryOrderStatus() and check the values in.
                      Cal H.NinjaTrader Customer Service

                      Comment


                        #12
                        OK thanks. Yes, this is my code to check the state:

                        Code:
                        string[] entryOrder = GetAtmStrategyEntryOrderStatus(orderIdLong);
                                        if (entryOrder.Length > 0)
                                        {
                                            if (entryOrder[2].ToString() == "Filled" || entryOrder[2].ToString() == "Rejected")
                                            {
                                                if (GetAtmStrategyMarketPosition(atmStrategyIdLong) == MarketPosition.Flat) orderIdLong = string.Empty;    // Order has been filled and has closed
                                            }
                        //                    if (entryOrder[2].ToString() == "Working" && Close[0] > )
                        //                    {
                        //                        if (GetAtmStrategyMarketPosition(atmStrategyIdLong) == MarketPosition.Flat) orderIdLong = string.Empty;    // Order has been filled and has closed
                        //                    }
                                        }
                        This line has me confused though:

                        if (entryOrder[2].ToString() == "Working" && Close[0] > x) // cancel a skipped order

                        How do I get the price that the stop order was at that was skipped? Do I just need to keep track of that with an internal variable or is this available in a property?

                        Thanks!
                        Bryan

                        Comment


                          #13
                          Bryan,

                          Use your IOrder object for this -

                          entryOrder.StopPrice will give you the stop price of your order.

                          http://www.ninjatrader.com/support/h...tml?iorder.htm
                          Cal H.NinjaTrader Customer Service

                          Comment


                            #14
                            StopPrice doesn't seem to be a valid property when you set entryOrder = GetATMStrategy...

                            See my attachment.

                            Thanks for your help!
                            Bryan
                            Attached Files

                            Comment


                              #15
                              Bryan,

                              Excuse me, I didn't register the AtmStrategy() with the StopPrice correctly.

                              You would need to store the stop price in a variable that you are passing through the CreateAtmStrategy(). This will allow you to check the Close[0] against the resting Stop price.
                              Cal H.NinjaTrader Customer Service

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                              0 responses
                              639 views
                              0 likes
                              Last Post Geovanny Suaza  
                              Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                              0 responses
                              366 views
                              1 like
                              Last Post Geovanny Suaza  
                              Started by Mindset, 02-09-2026, 11:44 AM
                              0 responses
                              107 views
                              0 likes
                              Last Post Mindset
                              by Mindset
                               
                              Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                              0 responses
                              569 views
                              1 like
                              Last Post Geovanny Suaza  
                              Started by RFrosty, 01-28-2026, 06:49 PM
                              0 responses
                              572 views
                              1 like
                              Last Post RFrosty
                              by RFrosty
                               
                              Working...
                              X