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

Backtesting and historical market hours

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

    Backtesting and historical market hours

    Hello,

    In a book I'm reading by Kevin Davey, he talks about making sure to test with consistent historical data. The example he uses is this:

    Let’s say you are trading gold, and you want to use 20 years (excellent choice!) of data, with 60‐minute bars. Twenty years ago, the pit was the only data source, so you have to use that. In a daily pit session, there were probably six to eight bars roughly (since pit trading hours over the years changed, the number of 60‐minute bars per day will change, too). For your strategy, let’s say you use a 14‐period moving average. This will typically represent two trading days. Now, fast‐forward to today’s electronic markets. Today’s markets trade for roughly 23 hours per day. If you still use a 14‐period moving average, that will only equate to a half trading day, instead of the previous two trading days. Do you think that can radically infl uence your historical tests? It sure can!
    I'm using NinjaTrader Continuum for my data and I'm wondering how these situations are dealt with. I'm not sure if I need to eliminate that period of data or if it is normalized somehow.

    Thank you!
    Paul

    #2
    Hello Paul, thanks for your post.

    The NinjaTrader historical data servers will provide up to two years of historical minute data and daily data back to 2009. Unless you have imported minute data going over 20 years back it would not be possible to pull this data from the historical data servers. If the data is different due to changes in exchange hours, the older data should not be included within the backtest where the ETH session is used, or include the old data and use the RTH session trading hours as the session template setting.

    Please let me know if I can assist any further.
    Chris L.NinjaTrader Customer Service

    Comment


      #3
      Hi Chris,

      It makes sense about specifically going back 20 years for Gold, but could you clarify a bit more about ETH and RTH? It would help me to use an example, so I'll just make one up. Let's say the hypothetical contract with symbol XYZ changed trading hours in 2016 from trading 12 hours per day to 23 hours per day. The regular trading hours before the change was 8:30 AM to 3:30 PM Eastern Time and now the RTH is 6 PM to 5 PM Eastern time.

      Using this example, would you please help me understand how using ETH and RTH would be used?

      Thank you!
      Paul

      Comment


        #4
        Hello Paul, thanks for your reply.

        In this scenario (for GC) you would use Nymex Metals RTH instead of the default Nymex Metals - Energy ETH because in 2016 only the RTH session existed. Doing this would make the data consistent throughout the entire data set.

        Please let me know if I can assist any further.
        Chris L.NinjaTrader Customer Service

        Comment


          #5
          That makes sense Chris thank you! Just one last question I think. If you use RTH does that mean the bars outside of those hours will not plot? I want to play around with that as well, but I wanted to ask first and then I can check the charts to see it in action. Thanks!

          Comment


            #6
            Hello Paul, thanks for your reply.

            Yes, that is correct. You can test this by opening up a chart, and switching the "Trading Hours" in the Data Series menu from ETH to RTH and you will notice there are less bars on the chart.

            Please let me know if I can assist any further.
            Chris L.NinjaTrader Customer Service

            Comment


              #7
              Sounds great Chris thanks! What is the reason behind things like Nymex Metals RTH1 through RTH5? Is there any documentation on what those are set to or anything?

              Comment


                #8
                Hello Paul, thanks for your reply.

                I have asked our product management team why these templates exist. I will update this thread with more information once I get a reply.

                Thanks in advance.
                Chris L.NinjaTrader Customer Service

                Comment


                  #9
                  Hello pdennis,

                  These Trading Hours templates can be referenced in the Trading Hours menu of the Control Center. They have different offsets for the start and end times of a session. If you loop through instruments in our database, we can see which instruments are configured to use this Trading Hours template as a default. (As I test, instruments using a Nymex TradingHours template are using the Energy ETH template.

                  Code:
                  foreach (Instrument inst in Instrument.All)
                  {
                      if (inst.MasterInstrument.TradingHours.Name.Contains( "Nymex Metals RTH"))
                          Print(inst.FullName + " " + inst.MasterInstrument.TradingHours.Name);
                  }
                  We look forward to assisting.
                  JimNinjaTrader Customer Service

                  Comment


                    #10
                    Hey thanks a lot Jim! Out of curiosity, what is the reason for having those multiple Trading Hours templates with the different offsets? It would not seem to be about time zones or a trader's personal preference, but it is significant enough for NinjaTrader to add them in the default list.

                    Thank you!
                    Paul

                    Comment


                      #11
                      Hello Paul, thanks for your reply.

                      Those extra templates cater to different RTH hours for various NYMEX products, though now most of them default to the ETH session. We have not removed them for legacy reasons in case traders are still using those templates.

                      Please let me know if this does not resolve your inquiry.
                      Chris L.NinjaTrader Customer Service

                      Comment


                        #12
                        Thank you Chris and Jim for your help and patience, that was very helpful!

                        Comment

                        Latest Posts

                        Collapse

                        Topics Statistics Last Post
                        Started by CortexZenUSA, Today, 12:53 AM
                        0 responses
                        1 view
                        0 likes
                        Last Post CortexZenUSA  
                        Started by CortexZenUSA, Today, 12:46 AM
                        0 responses
                        1 view
                        0 likes
                        Last Post CortexZenUSA  
                        Started by usazencortex, Today, 12:43 AM
                        0 responses
                        5 views
                        0 likes
                        Last Post usazencortex  
                        Started by sidlercom80, 10-28-2023, 08:49 AM
                        168 responses
                        2,265 views
                        0 likes
                        Last Post sidlercom80  
                        Started by Barry Milan, Yesterday, 10:35 PM
                        3 responses
                        11 views
                        0 likes
                        Last Post NinjaTrader_Manfred  
                        Working...
                        X