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

The bars that showed up Live and Strategy Analyzer are not identical

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

    The bars that showed up Live and Strategy Analyzer are not identical

    Hello,

    I have been running a strategy Live with the simulated account, and then I would go back and repeat the same day in the Strategy Analyzer environment (back test) using the same strategy. From my logs, I found out that the bars that showed up during Live and the Strategy Analyzer environment are not identical. They would generally look similar, but the Start/End time and the OHLC values for the bars are different. In both environments, I selected Break at EOD, what else do I need to do in order to have the bars show up the same? Thank you.

    Best,

    Billy

    #2
    Hello, I forgot to mention the chart I was using is the 2000 ticks chart for S&P 500 e-mini futures. Thanks.

    Comment


      #3
      Hi Billy, thanks for posting. lt would not be expected for this to happen in a normal running scenario. Please first try resetting your cache and if you continue to see the issue, please upload screen shots comparing the real time chart and the playback chart.

      To clear your data cache:
      Close NinjaTrader
      Navigate to \Documents\NinjaTrader 8\db\cache
      Delete all contents of the cache folder.
      Restart NinjaTrader and test again.
      Chris L.NinjaTrader Customer Service

      Comment


        #4
        Hello Chris,

        Thank you for your email, and Merry Christmas to you and your loved ones.

        Before I run the test as suggested, I observed something and I wonder if this is the key to the difference in the bars for live and backtest environments.

        In my backtest, I run my test in modified RTH trading hours (please see attached), instead of the default ETH trading hours. Could this be the source of the difference? Do I need to run my back test in the ETH trading hours in order to get the same bars that showed up in the live session?

        best,

        Bill

        Comment


          #5
          Hello Chris,

          I created a very simple strategy CaptureNTData (see attached CaptureNTData.txt) to print out the bars for trading hours RTH, ETH and RTH Modified (same as RTH except it starts at 0000H of the day instead of 0830H like RTH) for 2022-12-22. You can see that the bars printed out for 2022-12-22 are in the three files attached, and they are quite different from each other (I was looking for identical bars with start/end time, O, H, L, and C amongst the files). I plan to run the same strategy for the live session, and I expect the bars to be different too. My question is, how do I run a backtest such that the bars are identical to the live session? Your help is much appreciated.

          Best,

          Billy
          Attached Files

          Comment


            #6
            Hi Bill, thanks for the follow-up. Please first test on the default settings. If you get a difference in the bar's shape and composition while using your custom template and no difference when using the default session template then the custom time template is causing the difference. The tick bars would start accumulating at different times, thus causing them to break at different times so the composition of every bar since the start of the session could be different.
            Chris L.NinjaTrader Customer Service

            Comment


              #7
              Hello Chris,

              Thanks for your email, it looks like the bar difference for the tick chart is a common issue, see the discussion in this link:

              https://ninjatrader.com/support/foru...-discrepancies

              And according to the NinjaTrader document "Understanding why a chart can look different after reloading historical data from the server" explained why different is possible. The solution seems to be "Converting Real-Time Data into Historical Data", and using that converted historical data for the backtest to ensure identical bars. Is my understanding correct?

              Best,

              Billy
              Last edited by billythekid72; 12-27-2022, 10:05 AM.

              Comment


                #8
                Hello, thanks for your reply. Since you are using tick charts these links are 100% relevant to the situation. Its very easy for a tick chart to diverge since all it would take is a single tick to make all the difference. To ensure your backtests are using the exact same tick data that came in live you should record the incoming tick data to the disk.

                Kind regards,

                -ChrisL
                Chris L.NinjaTrader Customer Service

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by Jonafare, 12-06-2012, 03:48 PM
                5 responses
                3,985 views
                0 likes
                Last Post rene69851  
                Started by Fitspressorest, Today, 01:38 PM
                0 responses
                2 views
                0 likes
                Last Post Fitspressorest  
                Started by Jonker, Today, 01:19 PM
                0 responses
                2 views
                0 likes
                Last Post Jonker
                by Jonker
                 
                Started by futtrader, Today, 01:16 PM
                0 responses
                7 views
                0 likes
                Last Post futtrader  
                Started by Segwin, 05-07-2018, 02:15 PM
                14 responses
                1,792 views
                0 likes
                Last Post aligator  
                Working...
                X