Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Machine timezone effects backtest results

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

    Machine timezone effects backtest results

    I was running the same strategy using the same data on two different machines, and got different results. After a short analysis I realized the only difference was in the machines time zone settings.
    Some questions:
    • Doesn't NT compensate for my local settings? I would expect the same results regardless of the local machine.
    • In the OnBarUpdate() method, when I access Time[0], in which timezone is it?
    • I want to set my strategy to run between say 10:00 EST and 16:00 EST, regardless of where I run the strategy from. How should I go on about it?

    #2
    Hello boaza,

    Please note that NinjaTrader will use the time zone of your PC clock. However, if the same session template is selected for both backtests, it should not cause different results.

    What session template did you use? Please select the session template in the Session Manager in both PC's and check if they use the same settings. If the same session template is used, a different time zone will not make a difference.

    If you like the strategy to run between those times, I suggest to create a custom session template in the Session Manager. More information can be found at the link below.
    JasonNinjaTrader Customer Service

    Comment


      #3
      Hi Jason,
      I do see differences, so I guess it is due to my strategy. In the OnBarsUpdate() I compare Time[0] to several time spans, and behave differently according to the time. Therefore, I cannot use the simple 'Start session' / 'End Session' template.
      So I guess the question is: what time zone is used in OnBarsUpdate()? I'll manually normalize to EST.

      10x,

      Boaz

      Comment


        #4
        Hello Boaz,

        It will use the time zone of your PC clock. So you will need to adjust the code accordingly if the PC's use a different time zone.
        JasonNinjaTrader Customer Service

        Comment


          #5
          OK.

          Also, I would be grateful if you could explain how the Session template fits in all this. Namely:
          • Will OnBarUpdate() only be called within session hours?
          • Is the session info only used to close positions at end of day?
          • How will changing the Session's time zone effect my runs?


          Thanks,
          Boaz

          Comment


            #6
            Correct, you receive data as per the times of the session template, so OnBarUpdate() will only be called during session hours.

            The 'Exit on close' setting will use the end time of the session template that is selected.

            Your strategy will run as per the times of the session template. For example, you have a session template that runs from 9:00 AM to 3:00 PM. If you set the session template to Eastern time zone, it will run from 9:00 AM to 3:00 PM in Eastern time zone. If you set it to Central time zone, it will run at the same times but in Central time zone.
            JasonNinjaTrader Customer Service

            Comment


              #7
              Jason,
              I've just created a dummy strategy which prints Time[0]:
              Code:
                      /// <summary>
                      /// This method is used to configure the strategy and is called once before any strategy method is called.
                      /// </summary>
                      protected override void Initialize()
                      {
                          CalculateOnBarClose = true;
                      }
              
                      /// <summary>
                      /// Called on each bar update event (incoming tick)
                      /// </summary>
                      protected override void OnBarUpdate()
                      {
              			Print(Time[0].ToString());
                      }
              Running on a 1-min bar frame, I see a printout for every minute in the day (i.e. 24 hours), even when I select the 'CME FX Futures ETH' template (I'm running on 6E 09-11 data). What am I missing?

              Comment


                #8
                Please note that the ETH session templates runs almost 24/7 as well.

                Do you see printouts between 4:00 PM and 5:00 PM Central time? The CME FX Futures ETH session templates excludes data between these times.
                JasonNinjaTrader Customer Service

                Comment


                  #9
                  Jason,
                  This is really starting to blow my mind - I've added a few lines to my Timezone printer, so it prints the bar data (OHCLV), and an indication for the first bar of session:

                  Code:
                  protected override void OnBarUpdate()
                          {
                  			if(Bars.FirstBarOfSession)
                  				Print("First bar of session");
                  			String msg = String.Format("{0};{1};{2};{3};{4};{5}", Time[0].ToString(@"yyyyMMdd HHmmss"), Open, High, Close, Low, Volume); 
                  			Print(msg);
                          }
                  Then, I've ran it twice - first time setting my local machine timezone to EST, on the second - setting it to CST.

                  What I get is that the same data appears with the same timestamp (i.e. Time[0] is always EST, regardless of my local machine settings.
                  Second, In the CST trial, I got a one hour gap in bars between 16:00 to 17:00 (see below). What's going on?

                  Output for first run (EST):
                  20110103 165800;1.3359;1.3359;1.3358;1.3358;11
                  20110103 165900;1.3358;1.3359;1.3359;1.3358;5
                  20110103 170000;1.3359;1.3359;1.3359;1.3358;13
                  First bar of session
                  20110103 180100;1.335;1.3351;1.3349;1.3349;67
                  20110103 180200;1.3348;1.3348;1.3345;1.3344;75
                  20110103 180300;1.3345;1.3346;1.3341;1.3341;216
                  Output for second run (CST):
                  20110103 155800;1.3352;1.3353;1.3351;1.335;245
                  20110103 155900;1.3352;1.3352;1.335;1.335;87
                  20110103 160000;1.335;1.335;1.3348;1.3347;216
                  First bar of session
                  20110103 180100;1.335;1.3351;1.3349;1.3349;67
                  20110103 180200;1.3348;1.3348;1.3345;1.3344;75
                  20110103 180300;1.3345;1.3346;1.3341;1.3341;216
                  Notice the identical time stamp and data after 18:00

                  Comment


                    #10
                    Can you please tell me if you closed NinjaTrader when you changed the time zone of your PC clock.

                    If not, please test once more and close NinjaTrader in between the tests.
                    JasonNinjaTrader Customer Service

                    Comment


                      #11
                      I did close NT between trials, and recompiled the strategy

                      Comment


                        #12
                        You need to re-download your history. In DB the data is stamped with local time. It won't change if you change the zone, only new data will be different.

                        Comment


                          #13
                          What happens when you apply the strategy in a chart? It should not contain data between 16:00 and 17:00 Central time or 17:00 and 18:00 Eastern time. Subsequently, OnBarUpdate() is not called for this period either.
                          JasonNinjaTrader Customer Service

                          Comment


                            #14
                            Originally posted by Baruch View Post
                            You need to re-download your history. In DB the data is stamped with local time. It won't change if you change the zone, only new data will be different.
                            Doesn't the stamp include time zone info? I guess this also means I cannot mix and match different bars from different machines.
                            Can I somehow normalize existing data so it has the local timestamp?

                            Comment


                              #15
                              Can I somehow normalize existing data so it has the local timestamp?
                              The data has the local timestamp, without the zone. This is your problem.
                              Another way is Export/Import. In import you state what time zone the data is.

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by martin70, 03-24-2023, 04:58 AM
                              14 responses
                              105 views
                              0 likes
                              Last Post martin70  
                              Started by TraderBCL, Today, 04:38 AM
                              1 response
                              4 views
                              0 likes
                              Last Post bltdavid  
                              Started by Radano, 06-10-2021, 01:40 AM
                              19 responses
                              606 views
                              0 likes
                              Last Post Radano
                              by Radano
                               
                              Started by KenneGaray, Today, 03:48 AM
                              0 responses
                              4 views
                              0 likes
                              Last Post KenneGaray  
                              Started by thanajo, 05-04-2021, 02:11 AM
                              4 responses
                              470 views
                              0 likes
                              Last Post tradingnasdaqprueba  
                              Working...
                              X