Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Historical backtest - how to prevent invalid fills on higher timeframe ?

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

    Historical backtest - how to prevent invalid fills on higher timeframe ?

    Hi,
    I would like to ask, how to block invalid fills occuring on higher timeframes when
    testing multi-timeframe strategy.

    Example:
    Have a simple multi-timeframe strategy + we are using managed mode for order handling.
    We use 2 simple dataseries:
    • 15 minutes (primary timeframe = BarsArray[0])
    • 1 range (added dataseries for precise filling of orders = BarsArray[1]


    To get precise entry fill - we use this method with specified dataseries with index 1 = that's the 1-range dataseries.
    Code:
    EnterLongLimit(1, false, DefaultQuantity, entryPrice, "");
    We are ok with entry fills - they are precise = fill depends on 1-range bars, not on big 15-min bars.
    But in contrast - as we were precisely filled in entry order - we were not precisely filled on exit orders = we got INVALID FILL on 15-min timeframe. (when bar closed, backtesting engine detected, that profit price was hit that 15-min bar). And this is the problem.

    This occurs when the entry order and exit order prices are both within one 15 min bar. When 15-min bar closes - #onBarUpdate() method is called - an backtesting engine detects, that for example PT was hit. But in reality, the 15 min bar could never hit profit after entry.

    Quick example:

    EURUSD: 31.1.2011
    Trade entry: SHORT 1.3665 + profit and stoplosss are both 20 ticks



    Backtest reports invalid profit - due to M15 bar, that is so big, that it includes both entry and profit prices.


    So my question is, how to fix this in managed mode?
    • Is there any way, how to send profit and stoploss orders into the precise dataseries ?
      • ( currently, SetProfitTarget(...) and SetStoploss(...) do not have any parameter into which dataseries should be the order sent)

    • Or can I somehow ignore bigger dataseries, so it is now used in evaluating order fills?
    Attached Files
    Last edited by misova; 01-04-2014, 09:35 PM. Reason: Improved text

    #2
    Hello Misova,

    Thank you for your post.
    Originally posted by misova View Post
    So my question is, how to fix this in managed mode?
    • Is there any way, how to send profit and stoploss orders into the precise dataseries ?
    • Or can I somehow ignore bigger dataseries, so it is now used in evaluating order fills?
    There is no method to assign a dataseries to the Set() methods. You would need to use Exit() methods for this and adjust the Stop and Profit through your own custom code. There is also no method to "ignore" larger dataseries in the code for the Set() methods.

    This may be in relation to the Fill Type used for Historical Fills. Do you see the same item with the Stop Loss orders or just the Profit Targets? What is the Fill Type used for your strategy?

    I look forward to your response.

    Comment


      #3
      Hi Patrik,
      the same problem occurs with profit and also stoploss exits.
      When profit or stoploss exist in one M15 bar, then it is filled on close of that M15 bar.
      When both - profit and also stoploss is in one M15 bar, then stoploss is reported in backtest.

      I use standard "Default" Fill type.

      I looked at more discussion threads about similar problems, and I think, that there is no solution.
      It's technical problem of Ninjatrader's Managed mode.

      Is it really true, that the only solution is to program strategy Unmanaged mode ?

      Comment


        #4
        Hello misova,

        Thank you for your response.

        It's just that the Set() methods cannot be set to a DataSeries. You can still use the Exit() methods or as you stated the Unmanaged methods.

        Comment


          #5
          Hi Patrick,

          now I see, that much easier solution would be to use all Exit*** methods, but
          until this became clear to me I re-implemented complete strategy during these 2-3 days using Unmanaged mode

          I tested it and both approaches work fine.

          Thanks for your help.

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by Geovanny Suaza, 02-11-2026, 06:32 PM
          0 responses
          656 views
          0 likes
          Last Post Geovanny Suaza  
          Started by Geovanny Suaza, 02-11-2026, 05:51 PM
          0 responses
          371 views
          1 like
          Last Post Geovanny Suaza  
          Started by Mindset, 02-09-2026, 11:44 AM
          0 responses
          109 views
          0 likes
          Last Post Mindset
          by Mindset
           
          Started by Geovanny Suaza, 02-02-2026, 12:30 PM
          0 responses
          574 views
          1 like
          Last Post Geovanny Suaza  
          Started by RFrosty, 01-28-2026, 06:49 PM
          0 responses
          579 views
          1 like
          Last Post RFrosty
          by RFrosty
           
          Working...
          X