Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Impossible fills w/ backtesting

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

    Impossible fills w/ backtesting

    This could be a confusing post. Please hang in there and see if you can follow me.


    I'm adding 1-tick sub timeframe to my 1min strategy to try and get around the fact that Backtesting only knows the OHLC of the 1min bar. I was getting some impossible fills and figured a 1-tick sub timeframe would correct for that. It doesn't seem to be the case.




    When comparing backtest results with Market Replay, I see the backtest is still making impossible fills. The price (via Market Replay) in some cases doesn't come within a few ticks of hitting the limit buy price. Market Replay correctly doesn't have a fill. But the backtest does.

    I'm beside myself trying to figure out how this is possible. With a 1-tick sub timeframe, you can't go any smaller. Yet it is still filling when it should not (again, price doesn't come within 3-4 ticks in some cases).


    Assuming this is actually possible to do with NTraders backtesting, I cannot figure out what piece of the puzzle I'm missing.



    There is only one thing that I question. Maybe this is messing things up. Hopefully someone can clarify.

    1) Using BarsInProgress 0 (the 1min bars). I look at the current bar and compare it to previous 1min bars for my initial condition (condition1Long) to setup.

    2) Pretend condition1Long is now true. And because of that, on each BarsInProgress == 1 (1-tick setting) update, it looks for the price to go above the 1min bar high.

    3) When the price goes above that previous 1min bar high. It places a Limit buy order at a price BELOW the current market.

    4) This is where it gets screwy. For example, the price never comes back down within 3 or 4 ticks to allow for that Limit buy entry. However, in the 1min bar, the high and low span across both my entry and exit. Therefore faking out the backtest and making it think that a buy and sell happened. In reality, the price never dipped low enough to the buy limit price that happened in #2 above (the 1min bar that is in my limit-buy-price happened prior to the setup in #3).


    So I guess my question is. When you enter a:

    Code:
    longEntryOrder = SubmitOrder(0,OrderAction.Buy,OrderType.Limit,contracts,longEntryPrice,0,"","Long");
    Will the backtest treat that as a fill if the 1min bar goes below the limit price-- even though it happened prior to the setup?? Market Replay is doing it properly. The backtest is not. Something is screwy here and I'm wondering if the Backtest is getting confused because the 1min bar's low is below that limit price entry.

    I'm actually getting the results I'd expect if I wasn't using 1-tick sub timeframe.

    Do I need to wait for a setup, call that condition2Long, and watch the 1-tick price further for it to come back down to my entry and enter a market order instead of a limit? That is extra work and isn't as clean, but if this is the only way to get the backtest to work properly, I'll do it.


    Thank you!!
    Last edited by lookOutBelow; 02-08-2011, 07:16 PM.

    #2
    longEntryOrder = SubmitOrder(0,OrderAction.Buy,OrderType.Limit,cont racts,longEntryPrice,0,"","Long");
    Why don't you put the order for the secondary series?
    longEntryOrder = SubmitOrder(1,OrderAction.Buy,OrderType.Limit,contracts,longEnt ryPrice,0,"","Long");

    Comment


      #3
      Baruch is correct, you should submit the order to the secondary series for backtesting.

      Comment


        #4
        Thanks guys. I did overlook that.

        I also realized late last night that I misunderstood something else very important about Multi Timeframes...

        I mistakenly thought that if I wanted to access (for instance) the close of the 1-min bar, that I could still use Close[0] and if I wanted the close of the tick, I would use Closes[1][0]. I didn't realize that wouldn't work and I have to use Closes[0][0] to see the 1min close. This is correct isn't it?

        I'm going to change my code to reflect that and the suggestion by Baruch too. I'll come back here and report how it went.

        Thanks guys.
        Last edited by lookOutBelow; 02-09-2011, 08:36 AM.

        Comment


          #5
          Closes[0][0] == Close[0] on BarsInProcess == 0
          Closes[1][0] == Close[0] on BarsInProcess == 1

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by argusthome, 03-08-2026, 10:06 AM
          0 responses
          85 views
          0 likes
          Last Post argusthome  
          Started by NabilKhattabi, 03-06-2026, 11:18 AM
          0 responses
          47 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
          67 views
          0 likes
          Last Post Mindset
          by Mindset
           
          Working...
          X