Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Stop-Limit orders filled on touch with Default FillType

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

    Stop-Limit orders filled on touch with Default FillType

    Hello!

    When I backtest my strategy with Fill type = Default I see that Stop Limit orders are filled "on touch", before entry price is penetrated. This isn't expected, is it? How can I make the fills in backtest work as expected?
    • I'm on NT 7

    • I use the "advanced managed approach" with liveUntilCancelled = True
    • I use a 10 min ES chart where entry orders are submitted on bar close of the 10 min bars on a secondary 1 min TF with entry method EnterLongStopLimit(barsInProgressIndex = 1, liveUntilCancelled = TRUE, ....).
    • Stop price and limit price is set 1 tick above the current 10 min bar.
    • The option "Enforce Immediate Fills" is not checked under Tools/Options/Simulator.


    Below is an example, a chart, the Order tab data and the Execution Tab data. It's obvious that the order was filled intrabar "on touch".

    Code:
    Orders Tab																			
    Instrument	Action	Order Type	Qty	Limit	Stop	State	Filled	Avg Price	Remaining	Name	OCO	TIF	GTD	Account	Connection	ID	Strategy ID	Token	Time
    ES ##-##	Buy	StopLimit	1	1357,75	1357,75	Filled	1	1357,75	0	L_26_0011122010f0001000000_5		Gtc		Backtest		NT-00218		cec802458e3c4116ac9b8f9332888e72	2001-06-21 21:40
    Code:
    Executions Tab													
    Instrument	Action	Qty	Price	Time	ID	E/X	Position	Order ID	Name	Commission	Rate	Account	Connection
    ES ##-##	Buy	1	1357,75	2001-06-21 21:47	NT-00096	Entry	1L	NT-00218	L_26_0011122010f0001000000_5	0	1	Backtest
    Best Regards,
    poseidon_sthlm
    Attached Files
    Last edited by poseidon_sthlm; 11-20-2015, 07:56 AM.

    #2
    Hello poseidon_sthlm,

    Thanks for your post.

    Can you post your specific entry conditions and entry method employed?

    If you would prefer not to post in public, please send in to PlatformSupport[at]NinjaTrader[dot]com with a subject line of Forum Post: Stop-Limit orders filled on touch with Default FillType, Atten: Paul
    Paul H.NinjaTrader Customer Service

    Comment


      #3
      Hello again!

      I have attached a simplified strategy where stop-limit orders are filled "on touch" with FillType = Default. Orders are now submitted on bar close of the base TF, (and not on a secondary 1 min TF). The time stamps for the trades that are filled on touch will be printed in the ouput window when you run a backtest with this strategy. I assume that I have made some misstake, but I can not figure out what it may be. I appreciate your advice.

      Best Regards,
      poseidon_sthlm
      Attached Files
      Last edited by poseidon_sthlm; 11-23-2015, 01:01 AM.

      Comment


        #4
        Hello poseidon_sthlm,

        Thank you for your response.

        You have not made a mistake in your logic. It is actually how the historical fills are handled by the DefaultFillType.

        Whether you submit to the primary or secondary time frame for the Stop Limit order it will still follow the same process using the DefaultFillType for historical orders.

        This process is detailed in the file '@DefaultFillType.cs' under (My) Documents\NinjaTrader 7\bin\Custom\Type.

        To break it down, it first looks for the Stop price to be triggered. This is triggered by the Stop price being within the High and Low of the bar. Then it looks to see if the Limit price is within the High and Low and if so fills at the limit price level.

        So even if we submit to the 1 minute bar, the fill will occur at the Limit price.

        Please let me know if you have any questions.

        Comment


          #5
          Thanks for your reply.

          I was under the impression that stop-limit orders only fill if they are penetrated when fill type = default.

          It's written in the documentation,
          http://http://ninjatrader.com/support/helpGuides/nt7/
          Default
          An algorithm that takes a conservative and more realistic approach to filling limit and stop limit orders.
          • Limit orders only fill if the limit price was penetrated
          The comments in he file '@DefaultFillType.cs' under (My) Documents\NinjaTrader 7\bin\Custom\Type :
          Stop limit orders are triggered when traded at the stop price and traded through the limit price
          I do think this is a more realistic fill scenario for stop-limit orders and I do want the default fill type to behave as it's described in the documentation. My understanding of "penetrated" is that price has to trade at least 1 tick above the buy limit price for a stop-limit order to become filled. In that case the behaviour that you describe above for the default fill type would in my opnion be unexpected, wouldn't it?


          This is the code for stop-limit orders in Fill Type Default. The stop price must be penetrated by at least "epsilon" before the stop-limit order is triggered. What is NextHigh/NextLow? Is that the high/low of the CurrentBar or the next bar ( = one bar in the future)?
          Code:
          			else if (order.OrderType == OrderType.StopLimit)
          			{
          				// Stop limit orders are triggered when traded at the stop price and traded through the limit price
          				double nextLow	= NextLow;
          				double nextHigh = NextHigh;
          				if (!order.StopTriggered
          					&& ((order.OrderAction == Cbi.OrderAction.Buy
          							&& order.StopPrice <= nextHigh [B][COLOR="Red"]+ epsilon[/COLOR][/B])
          						|| (order.OrderAction == Cbi.OrderAction.BuyToCover
          							&& order.StopPrice <= nextHigh [B][COLOR="red"]+ epsilon[/COLOR][/B])
          						|| (order.OrderAction == Cbi.OrderAction.Sell
          							&& order.StopPrice >= nextLow [B][COLOR="red"]- epsilon[/COLOR][/B])
          						|| (order.OrderAction == Cbi.OrderAction.SellShort
          							&& order.StopPrice >= nextLow [B][COLOR="red"]- epsilon[/COLOR][/B])))
          					order.StopTriggered = true;													// stop limit order was triggered
          
          				if (order.StopTriggered
          					&& ((order.OrderAction == Cbi.OrderAction.Buy				
          							&& order.LimitPrice > nextLow + epsilon)
          						|| (order.OrderAction == Cbi.OrderAction.BuyToCover
          							&& order.LimitPrice > nextLow + epsilon)
          						|| (order.OrderAction == Cbi.OrderAction.Sell
          							&& order.LimitPrice < nextHigh - epsilon)
          						|| (order.OrderAction == Cbi.OrderAction.SellShort
          							&& order.LimitPrice < nextHigh - epsilon)))
          					FillPrice = order.LimitPrice;												// set fill price
          			}


          Best Regrads,
          poseidon_sthlm
          Last edited by poseidon_sthlm; 11-24-2015, 03:07 AM.

          Comment


            #6
            Hello poseidon_sthlm,

            You are correct once again. I believe we are both trying to say the same thing on the Default Fill Type.

            So let's go back and see what I missed in what you are saying is wrong. In your original screenshot did the 1 Minute bar ending at 9:47 PM not meet these conditions?

            Comment


              #7
              In my first post the stop-limit order was submited on bar close at 21:40 with stop price and limit price = 1357.75, that is 1 tick above the high of the current "setup bar". The order was filled (intrabar at 21:47 on the 1 min TF) on the next 10 min bar that closed at 21:50, although the high of this bar (=1357.75) only touched the stop price 1357.75, and thus the stop price was never penetrated . This order should not have been filled on this bar according to the rules of the default fill algorithm. So this is unexpected. I would expect the order to be canceled at the end of the 10 min bar that closed at 21.50 without any fill.

              You can reproduce similar situations with the simplified strategy that I have attached to post #3.

              What is NextHigh/NextLow in the file for FillTypes? Is that the high/low of the CurrentBar or the next bar ( = one bar in the future)?

              Best Regards,
              poseidon_sthlm
              Last edited by poseidon_sthlm; 11-24-2015, 09:24 AM.

              Comment


                #8
                Hello poseidon_sthlm,

                The price of the stop was reached and the fill occurred as the DefaultFillType would allow. I am not sure what you are seeing that suggests this fill should not have occurred.

                The NextHigh and NextLow are the next bar's high and low. The condition is checked on one bar and then submitted to the next bar, it must know that bar's high and low.

                Comment


                  #9
                  Ok, thanks for the explanation. I now understand that the fill type logic is based on the High/Low of the next bar. I read somewhere on this forum that NT never uses future bars for calculation, so I didn't expect that.

                  Best Regards,
                  poseidon_sthlm

                  Comment

                  Latest Posts

                  Collapse

                  Topics Statistics Last Post
                  Started by algospoke, Today, 06:40 PM
                  0 responses
                  9 views
                  0 likes
                  Last Post algospoke  
                  Started by maybeimnotrader, Today, 05:46 PM
                  0 responses
                  7 views
                  0 likes
                  Last Post maybeimnotrader  
                  Started by quantismo, Today, 05:13 PM
                  0 responses
                  7 views
                  0 likes
                  Last Post quantismo  
                  Started by AttiM, 02-14-2024, 05:20 PM
                  8 responses
                  168 views
                  0 likes
                  Last Post jeronymite  
                  Started by cre8able, Today, 04:22 PM
                  0 responses
                  9 views
                  0 likes
                  Last Post cre8able  
                  Working...
                  X