Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Comparing real-time, historical, and replay performance

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

    #16
    Originally posted by NinjaTrader_ChelseaB View Post
    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?'.

    The main reason is due to a lack of intra-bar granularity.

    See more about intra-bar granularity.
    https://ninjatrader.com/support/forum/forum/ninjatrader-8/strategy-development/94098-isfirsttickofbar-vs-onbarclose-for-backtest-live?p=773377#post773377

    By default when backtesting no intra-bar granularity is added. An added 1-tick series is necessary to increase fill accuracy to within 1 tick.
    Further, TickReplay is necessary for intra-bar indicator values to update and recalculate for on each tick or on price change Calculate setting.

    As a heads up, TickReplay cannot be used for accurate order fill prices and High Order Fill Resolution cannot be used in conjunction with TickReplay.


    Please note, as a script is enabled live on a chart or on the Strategies tab of the Control Center, the historical data will be processed first before the strategy transitions to processing real-time data. As the historical data is processed, this is the same as performing a backtest and will provide the same historical results as backtesting in the Strategy Analyzer.
    https://ninjatrader.com/support/foru...442#post782442


    Small differences in fill time, slippage, as well as small differences in when ticks are received and which bar they are included with can cause differences in the fill prices which aggregate in the total performance.

    For the tests to be even similar, it is necessary to test the exact same sets of data, without mixing and matching the data types. (Meaning it would not be wise for a comparison of real-time or playback to include historical data and the days tested must start and end on the same session)

    Its best to test by starting the strategy and reloading all historical data before running the test in real-time or playback.


    Once the basics of getting similar test environments (meaning same data set, and intra-bar granularity) have been satisfied, it becomes clearer how to spot exactly what has caused the differences in the order fills.

    Switching to view the chart may show that the charts appear very very similar but there are still differences in the final performance.

    Prints can be added to the script (or this information can be written to file if its a large amount of information) to further understand the behavior.

    See the post below about using prints for debugging.
    http://ninjatrader.com/support/forum...979#post510979


    This applies to NinjaTrader 7 as well, except for one large limitation: Tick Replay is a new concept developed for NinjaTrader 8 that is not implemented in NinjaTrader 7.

    The major difference with this is that indicators that need to update with CalculateOnBarClose as false will not be able to update with the secondary tick series. (The fill prices will use the secondary series, however, the indicators will not be updating tick for tick and will only update when the bar closes)

    Due to this, to get comparable results in NinjaTrader 7 for any scripts that call indicators the script must have CalculateOnBarClose set to True for all environments, real-time, historical (backtest), and replay.


    It can also be a challenge to know what information to print, and how to analyze the information once its printed. It was even a challenge for me putting this post together just getting the test data to be the same. (Printing the bar and tick information really helped with this)

    Below is a link to a set of videos I've created that demonstrate how to put this all together and analyze a small backtest in all three environments.
    World's leading screen capture + recorder from Snagit + Screencast by Techsmith. Capture, edit and share professional-quality content seamlessly.


    Attached is the modified SMACrossOver script I've written to test.
    where I can watch the videos?? it asks me for Adobe Flash Player, and I can't install it anymore.

    Comment


      #17
      Hello JesusSanchez,

      A new non-flash version of these videos, and others, are being processed.

      In the meantime, download or save the video, and use the Flash Projector to play videos that have been discontinued.

      Below is a publicly available link.
      Chelsea B.NinjaTrader Customer Service

      Comment


        #18
        Hello all.

        You can download all video on your PC(see attach) and open it with any VideoPlayer.
        Click image for larger version

Name:	2021-05-10_10-03-14.jpg
Views:	722
Size:	72.1 KB
ID:	1155375

        Comment


          #19
          Hi

          Trying to use this example I am facing this error: BAcktest no sense in this context, could someone guide to me?

          PLease, no care about this message...this morning my mind was not too clear....

          Regards
          Last edited by J2512; 09-12-2022, 11:47 AM.

          Comment


            #20
            Originally posted by J2512 View Post
            Hi

            Trying to use this example I am facing this error: BAcktest no sense in this context, could someone guide to me?

            PLease, no care about this message...this morning my mind was not too clear....

            Regards
            Hello J2515,

            Thank you for your note.

            Do you still require assistance or have a question about the backtest? We would be glad to assist if needed. If you were able to answer your question, please feel free to post your solution here in case it helps out a fellow forum user to answer their own question.

            Thank you for using NinjaTrader.

            Comment


              #21
              Good evening,

              I downloaded the SampleIntraBar script for ninjatrader 8 attached above. It shows on the chart but it is not listed under indicators on the strategy builder.

              Thanks

              Comment


                #22
                Hello conniejforextrader,

                Are you referring to the file that is attached to post 1 named RealtimeReplayHistoricalComparisonsExample_NT8.zip ?

                There is not a file attached to this post called SampleIntrabar, can you clarify what script you are referring to? ​

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                0 responses
                605 views
                0 likes
                Last Post Geovanny Suaza  
                Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                0 responses
                351 views
                1 like
                Last Post Geovanny Suaza  
                Started by Mindset, 02-09-2026, 11:44 AM
                0 responses
                105 views
                0 likes
                Last Post Mindset
                by Mindset
                 
                Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                0 responses
                560 views
                1 like
                Last Post Geovanny Suaza  
                Started by RFrosty, 01-28-2026, 06:49 PM
                0 responses
                561 views
                1 like
                Last Post RFrosty
                by RFrosty
                 
                Working...
                X