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

Data series inconsistancies?

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

    Data series inconsistancies?

    Hi NinjaTrader Support,


    I was doing some backtesting yesterday of one of my strategies , which runs in MES 23-09 - 15min chart, but also uses the MES 23-09 10 Tick data series, and I realised there were many data series inconsistencies between these two data series, over several periods: Basically the data seen on the screen (15 min time frame) didn't match the data accessed with the Close[0] function, 10 Tick time frame . As a result of that trades were triggered way higher/lower than the 15min bars were showing, like here (see the yellow dots):


    [attached pic]​


    Some of the periods where I clearly see the data series been off are:
    - 23 June 2023, from 14pm GMT+1 to 22pm GMT+1 (as seen in the picture above)

    Can you confirm this is an identified issue? Is this something that happens often? And what do you guys do to fix it, so that backtesting works accurately again?


    Thank you.

    #2
    Hello alrafer,

    Thanks for your post.

    I have created a simple test strategy that prints out the primary series (15-Minute MES 09-23) Close[0] price to a NinjaScript Output window.

    I ran a backtest on the test strategy and opened a Data Box window. I compared the Close price of each 15-minute bar to the Close price in the Data Box window and see the Close[0] print matches the Close price in the Data Box window.

    See this demonstration video showing the Close[0] price of the 15-minute bars match the 15-Minute bars on the Chart Display of the Strategy Analyzer window: https://brandonh-ninjatrader.tinytak...OV8yMTY4MjU1OQ

    If the strategy is not be having as you expect it to then you should add debugging prints to the script that print out the values being calculated in your strategy.

    Below is a link to a forum post that demonstrates how to use prints to understand behavior.
    https://ninjatrader.com/support/foru...121#post791121
    Brandon H.NinjaTrader Customer Service

    Comment


      #3
      Thanks so much for taking the time to look into this with such detail Brandon. My issue is related to the 15 min data series and the 10 Tick data series showing different data, for MES 09-23 and the aforementioned specified period. That doesn't make any sense since all the 10 Tick bar prices have to be included in the 15min bar prices, right? I do some calculations in the 15 min bars and move to the 10 Tick bar data to trigger the trade.

      I use this call to load the MES 09-23 10 tick data series:

      AddDataSeries(Data.BarsPeriodType.Tick, 10);

      Could you check again and validate if you see the discrepancy between these two data series? I see it clearly in my charts (that's why the trades shown in the attached pic start at prices that the 15min bars never reach).

      Thank you.

      Comment


        #4
        Hello alrafer,

        Thanks for your notes.

        I have tested this further and do not see any discrepancies between the 15-minute data series and the 10-Tick data series.

        The 15-minute data series will have a bar close at the end of each 15 minutes that pass whereas the 10-Tick series will have a new bar form for every 10 ticks that occur. This means there would be multiple 10-tick bars occurring for every 15-minute bar.

        Note that when using Calculate.OnBarClose, the 15-minute bar will only process logic at the close of each 15-minute bar. The 10-Tick bar will close once 10 ticks have occurred and is not a time-based data series.

        Further, when it comes to backtesting strategies, only the Open, High, Low, and Close will be available 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.

        You may use Tick Replay along with the added 10-tick series to have logic processed intra-bar and have orders filled intrabar.

        See this help guide page for more information: https://ninjatrader.com/support/help...ime_vs_bac.htm

        Additional information may be found in this NinjaTrader Forum post —
        https://ninjatrader.com/support/forum/forum/ninjatrader-8/strategy-development/100192-comparing-real-time-historical-and-replay-performance?t=102504
        Brandon H.NinjaTrader Customer Service

        Comment


          #5
          Hi again Brandon,

          My strategy just uses the ends of the bars (15min or 10Tick) to run , I know that, so all good on that front - no intrabar actions needed.

          But this is the data I get when I print it out via Output:

          ......... On 15Min Bars. High[0]: 4404. Low[0]: 4397. Time: 23/06/2023 20:15:00
          ================================================== ===================
          ......... On 10Ticks. Close[0]: 4390.75. Time: 23/06/2023 20:15:52
          ......... On 10Ticks. Close[0]: 4391.5. Time: 23/06/2023 20:17:02
          ......... On 10Ticks. Close[0]: 4390.25. Time: 23/06/2023 20:17:55
          ......... On 10Ticks. Close[0]: 4391.25. Time: 23/06/2023 20:19:07
          ......... On 10Ticks. Close[0]: 4392.25. Time: 23/06/2023 20:19:33
          ......... On 10Ticks. Close[0]: 4392.5. Time: 23/06/2023 20:20:12
          ......... On 10Ticks. Close[0]: 4391.25. Time: 23/06/2023 20:20:55
          ......... On 10Ticks. Close[0]: 4391.25. Time: 23/06/2023 20:21:54
          ......... On 10Ticks. Close[0]: 4390. Time: 23/06/2023 20:22:51
          ......... On 10Ticks. Close[0]: 4388.5. Time: 23/06/2023 20:23:05
          ......... On 10Ticks. Close[0]: 4388.75. Time: 23/06/2023 20:23:26
          ......... On 10Ticks. Close[0]: 4388.25. Time: 23/06/2023 20:23:55
          ......... On 10Ticks. Close[0]: 4388.75. Time: 23/06/2023 20:24:24
          ......... On 10Ticks. Close[0]: 4388.5. Time: 23/06/2023 20:25:22
          ......... On 10Ticks. Close[0]: 4388.25. Time: 23/06/2023 20:26:04
          ......... On 10Ticks. Close[0]: 4388.75. Time: 23/06/2023 20:27:00
          ......... On 10Ticks. Close[0]: 4388.25. Time: 23/06/2023 20:28:12
          ......... On 10Ticks. Close[0]: 4389.5. Time: 23/06/2023 20:29:21
          ================================================== ===================
          ......... On 15Min Bars. High[0]: 4400.5. Low[0]: 4395.75. Time: 23/06/2023 20:30:00
          ================================================== ===================
          ......... On 10Ticks. Close[0]: 4390. Time: 23/06/2023 20:30:56
          ......... On 10Ticks. Close[0]: 4390.5. Time: 23/06/2023 20:31:35
          ......... On 10Ticks. Close[0]: 4390.75. Time: 23/06/2023 20:32:18
          ......... On 10Ticks. Close[0]: 4390. Time: 23/06/2023 20:32:53
          ......... On 10Ticks. Close[0]: 4388.25. Time: 23/06/2023 20:33:09
          ......... On 10Ticks. Close[0]: 4388.25. Time: 23/06/2023 20:33:52
          ......... On 10Ticks. Close[0]: 4390.5. Time: 23/06/2023 20:34:46
          ......... On 10Ticks. Close[0]: 4392. Time: 23/06/2023 20:35:17
          ......... On 10Ticks. Close[0]: 4392.25. Time: 23/06/2023 20:35:58
          ......... On 10Ticks. Close[0]: 4392.25. Time: 23/06/2023 20:36:18
          ......... On 10Ticks. Close[0]: 4394. Time: 23/06/2023 20:36:33
          ......... On 10Ticks. Close[0]: 4393.5. Time: 23/06/2023 20:37:04
          ......... On 10Ticks. Close[0]: 4393. Time: 23/06/2023 20:37:51
          ......... On 10Ticks. Close[0]: 4393. Time: 23/06/2023 20:39:02
          ......... On 10Ticks. Close[0]: 4393.5. Time: 23/06/2023 20:40:09
          ......... On 10Ticks. Close[0]: 4391.75. Time: 23/06/2023 20:41:00
          ......... On 10Ticks. Close[0]: 4391. Time: 23/06/2023 20:41:42
          ......... On 10Ticks. Close[0]: 4392.75. Time: 23/06/2023 20:42:25
          ......... On 10Ticks. Close[0]: 4393. Time: 23/06/2023 20:43:10
          ......... On 10Ticks. Close[0]: 4393.75. Time: 23/06/2023 20:44:10
          ......... On 10Ticks. Close[0]: 4394. Time: 23/06/2023 20:44:46
          ......... On 10Ticks. Close[0]: 4394.5. Time: 23/06/2023 20:44:58​

          15min data and 10 Tick data intertwined. Please see the Times and the High/Low Values.
          To me it doesn't make any sense that the 10Tick data for the 15min time period is not included in the 15min bars data (I know one is time-related and the other is tick related). Additionally, my strategy is submitting trades based on the 10Tick bars at values that are not comprised in the 15 Min bars that I see on the screen.
          What am I missing here?

          Thanks again,


          Alberto.

          Comment


            #6
            Hello Alberto,

            Thanks for your notes.

            This could be caused by the Historical Tick/Minute data that you have downloaded.

            Please go to the Tools > Historical Data window and delete the Historical Tick data and Historical Minute data for the MES instrument by right-clicking on the 06/23/2023 date under the Tick and Minute sections in the Historical Data window and selecting 'Remove'. Then, redownload historical Tick and Minute data for the MES instrument for that date and retest to see if the behavior persists.

            Unfortunately, I am not able to download Historical Tick data for that specific date for that instrument on my end. If you see the problem persisting on that date, please download Historical Tick and Minute data for the MES instrument for 06/30/2023 and test the strategy on the date 06/30/2023 and report your results.

            How to delete Historical data: https://ninjatrader.com/support/help...HistoricalData
            How to download Historical data: https://ninjatrader.com/support/help...8/download.htm
            Brandon H.NinjaTrader Customer Service

            Comment


              #7
              Great suggestion - let me try that and come back to you with my feedback. Thanks!

              Alberto.

              Comment


                #8
                Hi Brandon,

                Yep it works now. I was using the 10tick data series without loading the tick data for these days previously. All this has happened cause I changed laptop and the new one didn't have any data stored in the DB, whereas the old one had 2 years of real time data loaded for many Instruments - therefore all my strategies using 10 Ticks data worked without issues.

                Thanks for the great clarification and resolution Brandon.

                Best,


                Alberto.

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by AaronKoRn, Today, 09:49 PM
                0 responses
                7 views
                0 likes
                Last Post AaronKoRn  
                Started by carnitron, Today, 08:42 PM
                0 responses
                9 views
                0 likes
                Last Post carnitron  
                Started by strategist007, Today, 07:51 PM
                0 responses
                10 views
                0 likes
                Last Post strategist007  
                Started by StockTrader88, 03-06-2021, 08:58 AM
                44 responses
                3,980 views
                3 likes
                Last Post jhudas88  
                Started by rbeckmann05, Today, 06:48 PM
                0 responses
                9 views
                0 likes
                Last Post rbeckmann05  
                Working...
                X