Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Fill Price on Limit Order after gap

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

    Fill Price on Limit Order after gap

    Hi,

    Doing a backtest. The Strategy enters at market and places a limit order to exit at the high of the bar (which was 259.08). This didn't fill for several bars, then there was a gap above this price. I would either expect the limit order to be cancelled or to be filled at the open price (264.27) of the gap up bar. But instead it was filled at the low of the day (260.61).

    Can you explain what is happening please. Is there anything I can do in my code to mitigate this?

    Thanks
    Click image for larger version

Name:	TSLA Limit Fill.png
Views:	64
Size:	20.6 KB
ID:	1321734

    #2
    Hello bubblegum,

    Regarding the price of the fill that would be determined by the fill engine calculating off the bar values and for the limit order that was the very likely the next best price that was traded once the limit was triggered which was the low of that bar.

    Comment


      #3
      But in other places on gaps, we get a fill at the open.

      Click image for larger version

Name:	Screenshot 2024-10-21 191637.png
Views:	42
Size:	9.0 KB
ID:	1322130

      The first picture above was a limit order. This one is a stop. Are they treated differently?

      Comment


        #4
        Hello bubblegum,

        Yes those are two different types of orders so to the fill engine they will be treated differently with respect to the type of order being filled. You can read about the fill engine here.

        Comment


          #5
          I read from this that if I check 'Fill Limit Orders on Touch' the fill will be at the Open. But it isn't. It stays at the Low. Thanks.

          Click image for larger version  Name:	Screenshot 2024-10-21 200835.png Views:	0 Size:	4.8 KB ID:	1322136

          Comment


            #6
            Hello bubblegum,

            Are you specifically using the option to fill limit orders on touch?

            Comment


              #7
              Whether I check the 'Fill Limit Orders on Touch' or not, the results are the same. It always fills at the Low.

              Comment


                #8
                Hello bubblegum,

                The 'Fill Limit Orders on Touch' means the order will fill if the price meets the order but does not cross (pass-through) the order. When disabled the price will have to pass through the order for the order to fill.



                With a stop order, this will become a market order and fill at market when touched. If the price gapped up, the first available price is the open of the bar.

                With a limit order, this fills at the specified price or better, but in backtest the full bar is taken into consideration.

                Yes, the fill price starts with the open.

                "d.Handle the special case of Limit orders with "Fill Limit Orders on Touch" enabled
                i.If the limit price has been touched, set the fill price to current bar Open"

                However after this, the price is set to be at the limit price, but 'clamped' to be inside of the bar. Since the limit price is below the bar, the order is clamped to the low of the bar so it is still inside the bar.

                ".Ensure the order would be filled without errors by comparing its stop and/or limit prices against each other and the current bar, then:
                i.For Limit orders, set the fill price to the current order's Limit price (however this is 'clamped' to happen inside the bar though)"


                Using High Order Fill Resolution or 1-tick intra-bar granularity with TickReplay depending on how the script is written, may give you more accurate results.
                Chelsea B.NinjaTrader Customer Service

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by NullPointStrategies, Today, 05:17 AM
                0 responses
                32 views
                0 likes
                Last Post NullPointStrategies  
                Started by argusthome, 03-08-2026, 10:06 AM
                0 responses
                124 views
                0 likes
                Last Post argusthome  
                Started by NabilKhattabi, 03-06-2026, 11:18 AM
                0 responses
                64 views
                0 likes
                Last Post NabilKhattabi  
                Started by Deep42, 03-06-2026, 12:28 AM
                0 responses
                41 views
                0 likes
                Last Post Deep42
                by Deep42
                 
                Started by TheRealMorford, 03-05-2026, 06:15 PM
                0 responses
                46 views
                0 likes
                Last Post TheRealMorford  
                Working...
                X