No announcement yet.

Partner 728x90


coping with daylight savings times in back testing and session templates

  • Filter
  • Time
  • Show
Clear All
new posts

    coping with daylight savings times in back testing and session templates


    I'm sure this is not an isolated problem that only I have, so hopefully this will be of use to many.

    I have 1 minute fx data spanning back many years. The issue I have is that i want to represent my daily bars for testing in london time.
    Typically you can just set the session template times for the appropriate timezone, however there's an issue:

    london has daylight savings time some parts of the year, where you would need to offset the bar data by 1 hour.
    Also, the data imported was from CQG (time reference Chicago time). The complication is then and different times of the year you need to offset one hour for the chicago daylight savings time also.
    The result is at different dates in the year, my data needs to be shifted by 0, 1 or 2 hours.

    From previous correspondance, the strategy backtest can be assigned the session template, so the daily bars constructed have the correct start/end time.
    How do you set it up to accomidate the above (different times of the year have offset start/end times).

    Note that the changes/shift in timezone occur over the weekend where FX is closed, so there is no issue of data overlap or an hour of data missing etc.



    Generally historical data that is saved is time stamped to your local PC. The session templates simply limit the data that displays on your chart to be between certain times. It is generally recommended to keep your PC clock synced to some time service, like NIST to avoid issues.

    Please let me know if I may assist further.
    Adam P.NinjaTrader Customer Service


      thanks for the reply. The data isn't from a broker connection. The data is from very reputable high quality 1 minute cqg data. the data varies throughout the year depending on the daylight saving time, and the issue as described below, if you say want to have your daily bars matched up to something like the london open or similar, means there's again different times of the day where there's an issue.

      How does the NT team suggest I approach this problem.

      Ideally there should be some way to set the session template for the backtest run THROUGHOUT the backtest run.
      So for example at a certain date (eg: at the end of the weekly session) i then change the session template, so for the next week the open/close times are correct.

      From what I understand it you currently assign all dataseries added to the strategy as whatever the session template is defined as in the parameters for the backtest/optimisation.

      Please advise.


        Hi PolarBear,

        Unfortunately NinjaTrader does not provide for dynamic session templates. They're set once per bar series. For any time-sensitive parts of your strategy, you would need to custom code what you would like to happen. This sample can help work with DateTime objects:
        Ryan M.NinjaTrader Customer Service


          Originally posted by PolarBear View Post
          ...How do you set it up to accomidate the above (different times of the year have offset start/end times)...
          You have a choice of two alternatives, I believe:
          a) leave your trading computer in Chicago time CST (even though it's located somewhere else), so that the operating system will make the correct adjustments for daylight saving in Chicago, with the result that your data will always be correct relative to CST (I do this: I'm in Europe, but trade US markets ... my trading computers are all in EST)
          b) convert your data to GMT (someone like the following could do this for you)


            thanks for this. You've prompted me to think of the best solution I believe. I hope this is of use to other trades.

            My (quite) simple solution is to just modify my C# executible I created that converts my original data into format suitable for NT6/7 import. In this code you simply have some kind of lookup table that provides the offset in hours within certain date ranges. When you parse the input file to output, you add/subtract the relevant hours to fix your data.
            You then import the data into NT and apply whatever session template you would like for your starting time of the day

            hope this helps some others.


            Latest Posts


            Topics Statistics Last Post
            Started by Renorail, Today, 01:38 PM
            1 response
            Last Post Renorail  
            Started by BrianARice, Today, 01:16 PM
            0 responses
            Last Post BrianARice  
            Started by Ousher, Today, 09:08 AM
            0 responses
            Last Post Ousher
            by Ousher
            Started by Unsuitable, Today, 08:41 AM
            0 responses
            Last Post Unsuitable  
            Started by newdill, Today, 07:54 AM
            0 responses
            Last Post newdill
            by newdill