Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Historical Data is not being reflected on charts / Data box does not match print data

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

    Historical Data is not being reflected on charts / Data box does not match print data

    Hello,

    I seem to be having issues with historical data on my charts. For instance, in the Historical Data window (under Tools), it shows that I have all historical data for August 25, 2023. Per this data, at 8am on this date, the M2K / RTY traded as low as 1834. However, my charts only reflect the price as having gone as low as 1850.

    Also, each time I backtest my strategy, the results are different. I'll backtest the strategy in the evening and obtain certain results, then I will backtest the exact same strategy the next day and get drastically different results (after adjusting for the 1 day difference in the backtesting period). I.e., new trades being taken, previous trades taken now being ignored. The results are all over the map, and they seem to change each day. I.e., I could run the backtest 10 times 1 day and get consistent backtest results, but the next day when I first run it, they will be completely different. I have tried clearing my cache, reloading historical data etc., but it does not help. I have also printed data values, then scrolled to that point on my charts, and often the data does not match what is displayed in the Data Box.

    Lastly, my chart will regularly freeze, and I get the error - Unhandled exception - Write Lock / Read Lock Deadlock....I've reviewed other posts on this but have not been unable to resolve this issue.

    I'm not sure if all these problems are related, but please help.


    #2
    Hello RideMe,

    Thanks for your post.

    What version of NinjaTrader are you using? Please provide the entire version number. This can be found under Help -> About (Example: 8.?.?.?)

    What is your Merge Policy setting set to in the Tools > Options > Market Data tab?

    Please send me a screenshot showing the OHLC values for an instrument in the Historical Data window values do not match the Data Box OHLC values when hovering the mouse over the same date/time on the chart so I may investigate this matter further.
    • To send a screenshot with Windows 10 or newer I would recommend using the Windows Snipping Tool.
    • Alternatively to send a screenshot press Alt + PRINT SCREEN to take a screenshot of the selected window. Then go to Start--> Accessories--> Paint, and press CTRL + V to paste the image. Lastly, save it as a jpeg file and send the file as an attachment.
    When backtesting, what is the instrument you are backtesting on and what are the dates you are using for the backtesting when you see the reported behavior occur?

    Note that if the data you are backtesting on is different in any way, such as different dates, the backtesting results will be different. As a general rule for backtesting: Same Input data + Same strategy code and parameters = Same results.

    In regard to the 'Unhandled exception' error message, please email support[at]ninjatrader[dot]com with a brief description of the error and attach your log and trace files to your email so a Support Technician may investigate this matter.

    Follow the steps below to manually attach your log and trace files to your email.
    • Open your NinjaTrader folder under, "Documents" (sometimes called, "My Documents")
    • Right click on the 'log' and 'trace' folders and select Send To> Compressed (zipped) Folder.
    • Send the 2 compressed folders as attachments to this email.
    • Once complete, you can delete these compressed folders.
    We look forward to assisting further.​
    Last edited by NinjaTrader_BrandonH; 09-19-2023, 12:21 PM.
    <span class="name">Brandon H.</span><span class="title">NinjaTrader Customer Service</span><iframe name="sig" id="sigFrame" src="/support/forum/core/clientscript/Signature/signature.php" frameborder="0" border="0" cellspacing="0" style="border-style: none;width: 100%; height: 120px;"></iframe>

    Comment


      #3
      Hi Brandon,

      Version No. is 8.1.1.6 64-bit

      Merge Policy is "Merge Back Adjusted"

      I am backtesting on the M2K over the last 180 days. The period is always over the last 180 days. I do appreciate that this means each day the period changes (lose the oldest day and gain the newest day), but this is not the issue. I've definitely considered this already.

      Screenshot.....

      Click image for larger version

Name:	image.png
Views:	297
Size:	495.0 KB
ID:	1269584

      Comment


        #4
        So I have changed the merge policy to "Merge Non Back Adjusted". Historical data now matches the data box and charts.

        This may have also been the cause of the inconsistent backtest results. After changing the merge policy, I re-ran the backtest and it had a drastic effect on the results. In fact the change made the results more consistent with the results I was receiving yesterday. However, it is a bit unusual given that I have never changed the merge policy (It was simply in its default setting - I think).​

        Comment


          #5
          Hello RideMe,

          Thanks for your notes.

          When using Merge Back Adjusted for the Merge Policy setting the data from each individual expiry month across the time span of the historical data request is loaded and offset values will be used to back-adjust the historical price data to match the next front month

          Since the date 08/25/2023 is included in the rollover from SEP23 to DEC23 and you are using 'Merge Back Adjusted' for the Merge Policy, you would need to apply the instrument's Offset to the price listed in the Historical Data window.

          If we go to the Tools > Instruments window, search for and select M2K, click the 'Contract months' field, and select 'DEC23' you can see the Offset value being applied.

          Merge Policy: https://ninjatrader.com/support/help...rge_policy.htm
          Instruments window: https://ninjatrader.com/support/help...nstruments.htm

          For example, if we test this using Historical Minute Data and compare the Close price on the Historical Data window to the Close price on the 1-Minute Chart, we can see that the price on the chart has the instrument's offset applied.

          The DEC23 Offset value for the M2K instrument is 18.1. The Historical Minute Data for 8:00 AM on 08/25/2023 has a Close price of 1860.4. The M2K 1-Minute Chart shows a Close of 1878.5.

          If we add the price Offset value to the Historical Data window Close price, this equals the price seen in the Data Box on the chart.

          1860.4 + 18.1 = 1878.5

          See the attached images.​
          Attached Files
          <span class="name">Brandon H.</span><span class="title">NinjaTrader Customer Service</span><iframe name="sig" id="sigFrame" src="/support/forum/core/clientscript/Signature/signature.php" frameborder="0" border="0" cellspacing="0" style="border-style: none;width: 100%; height: 120px;"></iframe>

          Comment


            #6
            Hi Brandon. Thank you. This all makes sense now. Could this explain why I keep getting different backtest results? I would assume that the offsetting values would affect the indicators values used in the strategy. If the mergy policy is set to Merge Back Adjusted, would there be a new/updated offset calculation each day that could affect backtest results?

            Comment


              #7
              Hello RideMe,

              Thanks for your notes.

              You mentioned "I am backtesting on the M2K over the last 180 days. The period is always over the last 180 days."

              If you are not testing over the same exact dates each time then the data you are backtesting on would be different each day. Since the data being backtested on is different, the backtesting results will be different too.

              For example, say you run a backtest today (09/19/2023) with the backtesting Start Date set to 08/18/2023 and End Date set to 09/18/2023.

              Then, tomorrow (09/20/2023) you run a backtest with the Start Date set to 08/19/2023 and End Date set to 09/19/2023 and compare the results to the prior day's backtest, the results will be different because you are backtesting different data from different days.

              Now, say you run a backtest today (09/19/2023) with the backtesting Start Date set to 08/18/2023 and End Date set to 09/18/2023. Then, tomorrow (09/20/2023) you run a backtest using the same Start Date of 08/18/2023 and same End Date of 09/18/2023. The backtest results would be the same since the exact same data is being backtested.

              Anytime the data you are backtesting on changes, such as changing the dates you are backtesting over, the backtesting results will be different.
              <span class="name">Brandon H.</span><span class="title">NinjaTrader Customer Service</span><iframe name="sig" id="sigFrame" src="/support/forum/core/clientscript/Signature/signature.php" frameborder="0" border="0" cellspacing="0" style="border-style: none;width: 100%; height: 120px;"></iframe>

              Comment


                #8
                Hi Brandon,

                Yes, I am aware the backtest results will change in that manner. However, trades taken on 178 out of 180 days should still be the same. This is not however the case. Numerous trades throughout the period are changing. This is based on a lot of data and review. It is simply skipping trades it use to take and picking up new ones it never previously took all throughout the 180 day period - many of which are in the middle of the period. This has nothing to do with the rolling 180 day period being used - I have already accounted for those resulting changes.

                Comment


                  #9
                  Hello RideMe,

                  Thanks for your notes.

                  This is the expected behavior when backtesting different dates and comparing it to a previous backtest that uses different dates. Anytime a date you are backtesting over is different, this means different data is used and it will cause the entire backtest to be different, not just the changed days you are backtesting on.

                  For example, if there was even a 1-Tick difference in the historical data being backtested on then the entire backtest results could be different for all 180 days you are testing over.

                  If you want to see the same backtest results then you would have to run backtests on the same exact dates each time the backtest is run.
                  <span class="name">Brandon H.</span><span class="title">NinjaTrader Customer Service</span><iframe name="sig" id="sigFrame" src="/support/forum/core/clientscript/Signature/signature.php" frameborder="0" border="0" cellspacing="0" style="border-style: none;width: 100%; height: 120px;"></iframe>

                  Comment

                  Latest Posts

                  Collapse

                  Topics Statistics Last Post
                  Started by NullPointStrategies, Today, 05:17 AM
                  0 responses
                  50 views
                  0 likes
                  Last Post NullPointStrategies  
                  Started by argusthome, 03-08-2026, 10:06 AM
                  0 responses
                  126 views
                  0 likes
                  Last Post argusthome  
                  Started by NabilKhattabi, 03-06-2026, 11:18 AM
                  0 responses
                  69 views
                  0 likes
                  Last Post NabilKhattabi  
                  Started by Deep42, 03-06-2026, 12:28 AM
                  0 responses
                  42 views
                  0 likes
                  Last Post Deep42
                  by Deep42
                   
                  Started by TheRealMorford, 03-05-2026, 06:15 PM
                  0 responses
                  46 views
                  0 likes
                  Last Post TheRealMorford  
                  Working...
                  X