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.
      BertrandNinjaTrader Customer Service

      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 ender_wiggum, Today, 09:50 AM
          1 response
          5 views
          0 likes
          Last Post NinjaTrader_Gaby  
          Started by rajendrasubedi2023, Today, 09:50 AM
          1 response
          11 views
          0 likes
          Last Post NinjaTrader_BrandonH  
          Started by geotrades1, Today, 10:02 AM
          0 responses
          4 views
          0 likes
          Last Post geotrades1  
          Started by bmartz, Today, 09:30 AM
          1 response
          8 views
          0 likes
          Last Post NinjaTrader_Erick  
          Started by geddyisodin, Today, 05:20 AM
          3 responses
          25 views
          0 likes
          Last Post NinjaTrader_Gaby  
          Working...
          X