Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

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.


    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:	506
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.
            Emily C.NinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by kevinenergy, 02-17-2023, 12:42 PM
            117 responses
            2,764 views
            1 like
            Last Post jculp
            by jculp
             
            Started by Mongo, Today, 11:05 AM
            5 responses
            15 views
            0 likes
            Last Post NinjaTrader_ChelseaB  
            Started by SightCareAubetter, Today, 12:55 PM
            0 responses
            3 views
            0 likes
            Last Post SightCareAubetter  
            Started by traderqz, Today, 12:06 AM
            8 responses
            16 views
            0 likes
            Last Post traderqz  
            Started by SightCareAubetter, Today, 12:50 PM
            0 responses
            2 views
            0 likes
            Last Post SightCareAubetter  
            Working...
            X