Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Early Fill on Stop Price

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

    Early Fill on Stop Price

    Hi,

    Can anyone please explain why I am getting an early fill.

    I have a short position with an exit order, on stop, at a specific stop price. I have a trailing stop. The position is closing early, before the trailing stop is hit.

    High[0]) = 1137.7

    OnOrderUpdate():
    stopOrder = Order='NT-00001/Backtest' Name='ShortStop' State=Working Instrument='TF 09-14' Action=BuyToCover Limit price=0 Stop price=1137.9 Quantity=1 Strategy='PB_TrailStopStrategy' Type=Stop Tif=Day Oco='' Filled=0 Fill price=0 Token='ff1a8cffecf747dabac858420773bdd6' Gtd='12/1/2099 12:00:00 AM'

    Notice that the above clearly states the
    State = Working
    Stop Price = 1137.9

    OnOrderUpdate():
    stopOrder = Order='NT-00001/Backtest' Name='ShortStop' State=Filled Instrument='TF 09-14' Action=BuyToCover Limit price=0 Stop price=1137.9 Quantity=1 Strategy='PB_TrailStopStrategy' Type=Stop Tif=Day Oco='' Filled=1 Fill price=1137.9 Token='ff1a8cffecf747dabac858420773bdd6' Gtd='12/1/2099 12:00:00 AM'

    Notice that the above clearly states the
    State = Filled !!!!!!!!!!!!!!!!!!!!
    Stop Price = 1137.9
    Fill Price = 1137.9

    OnExecution(): stopOrder 3 = Order='NT-00001/Backtest' Name='ShortStop' State=Filled Instrument='TF 09-14' Action=BuyToCover Limit price=0 Stop price=1137.9 Quantity=1 Strategy='PB_TrailStopStrategy' Type=Stop Tif=Day Oco='' Filled=1 Fill price=1137.9 Token='ff1a8cffecf747dabac858420773bdd6' Gtd='12/1/2099 12:00:00 AM'

    Why am I getting a fill at 1137.9 when the current high is 1137.7 (short position). Does this have anything to do with the slippage being set to 2 ticks?

    #2
    Zeos6, correct the slippage would be applied directly per seen execution for your non limit orders. Have you compared the same trade to a run with no slippage? Although it should not allow you to get an execution outside chart bar. What day / timeframe on the TF was this seen on?

    Comment


      #3
      Hi Bertrand,

      Thanks for your reply. I get the same early fill even when I set Slippage = 0; This Occurred on the 5 min TF candle chart, July 27, 2014, at 19:10.

      Comment


        #4
        Thanks, I see it now - I don't think you compare to the correct bar - which timestamp does the actual execution hold in the report for the stop out? I'm pretty sure that would 19:15.

        Comment


          #5
          Hi Bertrand,

          Thanks for the quick reply. I am really glad you see the issue. The stop out occurs at 19:10. The info for the 19:10 bar is:

          OnExecution(): stopOrder = Order='NT-00001/Backtest' Name='ShortStop' State=Filled Instrument='TF 09-14' Action=BuyToCover Limit price=0 Stop price=1137.9 Quantity=1 Strategy='PB_TrailStopStrategy' Type=Stop Tif=Day Oco='' Filled=1 Fill price=1137.9 Token='e10a00d0fe36414fb42f551dcf8ef337' Gtd='12/1/2099 12:00:00 AM'

          The 19:15 info is

          7/27/2014 7:15:00 PM Entered internal PlaceOrder() method at 7/27/2014 7:15:00 PM: BarsInProgress=0 Action=SellShort OrderType=Stop Quantity=1 LimitPrice=0 StopPrice=1137.4 SignalName='ShortEntry' FromEntrySignal=''

          entryOrder = Order='NT-00002/Backtest' Name='ShortEntry' State=PendingSubmit Instrument='TF 09-14' Action=SellShort Limit price=0 Stop price=1137.4 Quantity=1 Strategy='PB_TrailStopStrategy' Type=Stop Tif=Day Oco='' Filled=0 Fill price=0 Token='f445757a34c34fdcad346433af710891' Gtd='12/1/2099 12:00:00 AM'

          This is a new short entry. The position is closed at 19:10 - the wrong bar.
          Last edited by Zeos6; 08-15-2014, 11:18 AM.

          Comment


            #6
            That's from TraceOrders right, however what I'm interesting in is the execution timestamp you get from backtesting your script. Just open up the performance report and then check the executions you get. Which time is listed for the stop out there. As you cannot print / compare to the bar reported from OnOrderUpdate/OnExecution.

            Comment


              #7
              Hi Bertrand,

              Thanks for the quick reply. You are correct, the previous info is from the Trace Orders. The time stamps from the Trades tab in the Strategy Analyzer window show:

              Entry Time = 7/27/2014 7:05:00 PM <--- this is correct
              Exit Time = 7/27/2014 7:15 PM <--- that is what shows on the chart and what should be correct

              What is happening, however, is that because the strategy code shows the position as flat at 19:15, I am getting an entry that should not be there. How can I fix this?

              Comment


                #8
                Zeos6,

                You can use the BarsSinceExit() to have your strategy wait a number of bars after an exit before it can place another trade.
                http://www.ninjatrader.com/support/h...ssinceexit.htm
                Cal H.NinjaTrader Customer Service

                Comment


                  #9
                  Hi Cal,

                  Thank you for that information. It is useful, but I think it misses the point of my question. The real issue to me is the following:

                  Why is it that when processing historical bars, the TraceOrders shows the position closing on the previous bar to the bar on which the execution time stamp takes place? The BarsSinceExit() seems to be a workaround. Can you please explain the rationale for the difference between the TraceOrders information and the execution time stamp information for historical bar data?

                  Comment


                    #10
                    Zeos,

                    The signal that caused your strategy to place the order was from that bar before, but remember that bar has technically closed and thus the orders are placed and the FillType looks at the next bar to see if the price will get filled or not. If it is filled the execution is then placed on that next bar.
                    Cal H.NinjaTrader Customer Service

                    Comment


                      #11
                      Hi Cal,

                      Thank you for your reply. You say that the signal to place the order came from the preceding bar, on the close of the bar. I understand that, but that throws off the rest of my strategy as there are other parts that depend on the execution taking place on the correct bar, not the previous bar. Is there a workaround that would help me get around this? Checking for stopOrder or entryOrder objects equal to null will not help as both become null on the previous bar. I need something that actually becomes null on the bar on which execution takes place.

                      BTW, I looked at creating my custom fill type but there is very little documentation available. Is there documentation?

                      Comment


                        #12
                        Hello Zeos6,

                        Thank you for your response.

                        If you cannot call the IOrder.Time, then you would need to adjust you code to compensate for the the different timestamp of the execution.

                        Comment


                          #13
                          Hi PatrickH,

                          Thank you for your reply. I now have sufficient information regarding the sequencing and placement of orders during back testing. Consequently I was able to restructure my code and the code now works correctly. Thank you for all the patience and the help I received from the entire team.

                          Comment

                          Latest Posts

                          Collapse

                          Topics Statistics Last Post
                          Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                          0 responses
                          647 views
                          0 likes
                          Last Post Geovanny Suaza  
                          Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                          0 responses
                          367 views
                          1 like
                          Last Post Geovanny Suaza  
                          Started by Mindset, 02-09-2026, 11:44 AM
                          0 responses
                          108 views
                          0 likes
                          Last Post Mindset
                          by Mindset
                           
                          Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                          0 responses
                          571 views
                          1 like
                          Last Post Geovanny Suaza  
                          Started by RFrosty, 01-28-2026, 06:49 PM
                          0 responses
                          573 views
                          1 like
                          Last Post RFrosty
                          by RFrosty
                           
                          Working...
                          X