Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Backtesting use end of bar execution moment

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

    Backtesting use end of bar execution moment

    I struggle with the execution moment when backtesting, hope someone can make me clear as I already searched a lot for this topic here. I have a condition in the strategy builder that enters a long buy at the lower Bollingerband (and exits a short). In the playback connection this is working well and the entry is executed at the lower BB! When I want to backtest this for the results the order is executed at the open of the bar instead at the lower BB, of course this gives totally different results! I tried this without and with tick data. How can I get the backtest results with the order excecuted at the price of the lower BB instead end of the bar?
    Attached Files

    #2
    Hello FrankNetherlands,

    Thank you for your post.

    You should expect that a strategy running real-time (live brokerage account, live market simulation, Market Replay using the Playback connection etc...) will produce different results than the performance results generated during a backtest. This difference may be more easily seen on certain Bars types (e.g. Point and Figure, renko) than others due to their inherent nature in bar formation.

    During a backtest you can select conservative or liberal fill algorithms which will produce different results. Fills are determined based on 4 data points, OHLC of a bar since that is the only information that is known during a backtest and there will be no intra-bar data. This means actions cannot happen intra-bar, fills cannot happen intra-bar. All prices and actions come from and occur when the bar closes as this is all the information that is known.

    Because of this, OnBarUpdate will only update 'On bar close' as it does not have the intra-bar information necessary for 'On price change' or 'On each tick'.

    Also, here is a link to the differences on real-time vs backtest (historical).


    Adding intra-bar granularity can help with this.

    Intra-bar granularity adds a second data series such as a 1 tick series so that the strategy has finer granularity in the historical data in between the OHLC of the primary series. This allows for more accurate trades by supplying the correct price at the correct time for the order to fill with.

    In NinjaTrader 8, there have been two new enhancements so that programmers do not have to manually add this secondary series and code the script to for high accuracy fills (Order Fill Resolution) and for intra-bar actions (TickReplay).

    Here is a link to our forums that goes into depth on using Order Fill Resolution and Tick Replay to ensure your backtests are as close to real time results as possible:

    Citizens of the NinjaTrader Community, A common question we hear from clients is 'why are results from backtest different from real-time or from market replay?'. Live orders are filled on an exchange with a trading partner on an agreed upon price based on market dynamics. Backtest orders are not using these market dynamics.


    High Fill Order Resolution and TickReplay cannot be used together. If it is necessary to have both, it is still possible to add intra-bar granularity to a script in the code itself for order fill accuracy and use TickReplay to update indicators with Calculate set to OnPriceChange or OnEachTick historically.

    Please let us know if we may be of further assistance to you.
    Kate W.NinjaTrader Customer Service

    Comment


      #3
      Thank you for the quick response and explanation, already read a lot, but a little bit overwhelming, did I understand right:

      - The tick replay is only for calculating indicators, not for accurate order fill prices?

      - Playback on the other hand is using ticks for calculating intra-bar order fill prices?

      Further more I don't understand what the difference is between historical and real time data.



      Comment


        #4
        Hello FrankNetherlands,

        Thank you for your reply.

        Yes, tick replay would be for indicator calculations and would not affect order fill prices.

        The Playback connection used with Market Replay data would play back the data in real time just as it occurred during that day and would be my personal recommended method of testing as it will most closely reflect what the strategy would have done.

        Historical data is the data that is on your chart prior to the current bar. Real time data can be thought of as what makes up the current price of the currently forming bar - it's the new data that is coming in.

        Please let us know if we may be of further assistance.
        Kate W.NinjaTrader Customer Service

        Comment


          #5
          Hello Kate,

          Thank you for your clear answers, this are exactly the answers I was looking for lately!

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by f.saeidi, Yesterday, 12:14 PM
          9 responses
          23 views
          0 likes
          Last Post f.saeidi  
          Started by Tim-c, Today, 03:54 AM
          0 responses
          3 views
          0 likes
          Last Post Tim-c
          by Tim-c
           
          Started by FrancisMorro, Today, 03:24 AM
          0 responses
          3 views
          0 likes
          Last Post FrancisMorro  
          Started by Segwin, 05-07-2018, 02:15 PM
          10 responses
          1,772 views
          0 likes
          Last Post Leafcutter  
          Started by Rapine Heihei, 04-23-2024, 07:51 PM
          2 responses
          31 views
          0 likes
          Last Post Max238
          by Max238
           
          Working...
          X