Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Backtesting for 1 day period, includes trades from the previous day

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

    Backtesting for 1 day period, includes trades from the previous day

    Hello,
    I am trying to do a walk-forward optimization for a high-frequency strategy, where I test 1 day and then backtest for the 1 day that follows.

    I noticed that there's an issue because some trades are included from the previous day (which was used during the optimization).

    For instance, if I do an optimization for 12 May 2020, there are trades included from the last 7-8 hours of 11th May in the optimization chart (and in the summary).

    I am based in Europe (GMT + 3) which is 7 hours ahead of New York. Not sure if that is a factor here.

    I am attaching a screenshot.










    #2
    Hello nikolaalx,

    Thank you for your note.

    The default trading hours template for the ES is the CME US Index Futures ETH, which would start at 5pm US Central and run through 4pm US Central on the next day, so it would be expected that some data from the 11th would be included when loading the 12th's ETH session. If you're looking to restrict it to the day's RTH session, you can specify that template in the Session Template field right underneath the dates and it will restrict the strategy to only the RTH hours.

    Please let us know if we may be of further assistance to you.
    Kate W.NinjaTrader Customer Service

    Comment


      #3
      Originally posted by NinjaTrader_Kate View Post
      Hello nikolaalx,

      Thank you for your note.

      The default trading hours template for the ES is the CME US Index Futures ETH, which would start at 5pm US Central and run through 4pm US Central on the next day, so it would be expected that some data from the 11th would be included when loading the 12th's ETH session. If you're looking to restrict it to the day's RTH session, you can specify that template in the Session Template field right underneath the dates and it will restrict the strategy to only the RTH hours.

      Please let us know if we may be of further assistance to you.
      Hello,
      I am +3 GMT, which means I am exactly 8 hours ahead of US central time.

      The chart I have shown you reflects my local time. This means that the encircled trades at around 16h-17h GMT+3 translate to 08:00am - 09:00 am US Central time 11th May.

      Why are trades dating from early morning on May 11th being optimized when I have specifically configured May 12th as the sole day for optimization?

      Are you sure the issue is in the trading session configuration? From what I see, the trades are happening way before the end of the trading session.

      Comment


        #4
        Hello nikolaalx,

        Thank you for your reply.

        Yes, it's due to the session template. Since part of the ETH session is on the previous date, what occurs in NT7 is basically "Session bleed" as one of my colleagues put it. What occurs when you test a single date using a session template like the ETH template is that the Strategy Analyzer will retrieve data for dates that have sessions that overlap your chosen day. So, if you backtest over the 12th, I would expect to see trades on the 11th, 12th, and 13th, since all of those dates have sessions that start or end on the 12th.

        This is handled much better in NinjaTrader 8, which doesn't have that session bleed - if you choose a single date in the strategy analyzer using an ETH template in NinjaTrader 8, it will only show results for the ETH session that ends on the date selected. You may want to consider migrating to the newer version.

        Please let us know if we may be of further assistance to you.
        Kate W.NinjaTrader Customer Service

        Comment


          #5
          Originally posted by NinjaTrader_Kate View Post
          Hello nikolaalx,

          Thank you for your reply.

          Yes, it's due to the session template. Since part of the ETH session is on the previous date, what occurs in NT7 is basically "Session bleed" as one of my colleagues put it. What occurs when you test a single date using a session template like the ETH template is that the Strategy Analyzer will retrieve data for dates that have sessions that overlap your chosen day. So, if you backtest over the 12th, I would expect to see trades on the 11th, 12th, and 13th, since all of those dates have sessions that start or end on the 12th.

          This is handled much better in NinjaTrader 8, which doesn't have that session bleed - if you choose a single date in the strategy analyzer using an ETH template in NinjaTrader 8, it will only show results for the ETH session that ends on the date selected. You may want to consider migrating to the newer version.

          Please let us know if we may be of further assistance to you.
          Thank you for clarifying.

          Unfortunately, migrating to NT8 at the moment is not an option as I have no experience with it, and I am not sure I will manage with the ninjascript editor.

          For the time being I will have to "hack" this by utilizing the proper session template.

          Is there a specific session template that you can recommend for me to use so that I ensure there is no such session bleeding and be able to do a 1:1 walk forward optimization?

          Comment


            #6
            Hello nikolaalx,

            Thank you for your reply.

            I'd try the CME US Index Futures RTH template. That one works for me and only loads the single day of data since the session doesn't overlap days.

            Please let us know if we may be of further assistance to you.
            Kate W.NinjaTrader Customer Service

            Comment


              #7
              Originally posted by NinjaTrader_Kate View Post
              Hello nikolaalx,

              Thank you for your reply.

              I'd try the CME US Index Futures RTH template. That one works for me and only loads the single day of data since the session doesn't overlap days.

              Please let us know if we may be of further assistance to you.
              Hello, The CME Index RTH have a much smaller session (similar to the one of Stocks) and, as a result, I am missing out the most part of the action.

              I've created a custom session with the following settings:

              Sunday: 12:00 AM - Sunday: 11:59 PM
              Monday: 12:00 AM - Monday: 11:59 PM
              Tuesday: 12:00 AM - Tuesday: 11:59 PM
              Wednesday: 12:00 AM - Wednesday: 11:59 PM
              Thursday: 12:00 AM - Thursday: 11:59 PM
              Friday: 12:00 AM - Friday: 11:59 PM
              Saturday: 12:00 AM - Saturday: 11:59 PM

              I have configured this session to be matching the exact same timezone (assuming that when I use the strategy optimizer, when I select specific dates, the selection is based on my local time zone).

              When I do a 1 day: 1 day walk forward optimization, I am able to verify that by using this session, I don't see trades bleeding from surrounding days.

              There is however another problem. Some days just appear as blank..despite the fact that there is only 1 minute missing from each day of the week. Technically my session is almost identical to the 24/7 session template.

              I verified that there is marked data present for these days.

              I am attaching a screenshot.

              Am I doing anything wrong and is there a way to avoid these blind spots in the walk forward? They are really ruining the whole analysis.


              Attached Files

              Comment


                #8
                Hello nikolaalx,

                Thank you for your reply.

                Some dates I would not expect to see anything on, if they fall on the weekend when the markets are closed - keep in mind that between Friday at 4:00 PM US CST and Sunday at 5 PM US CST no data will exist.

                However, the other days look like missing data couldn't be filled in for those dates. I would suggest using the Historical Data Manager to redownload tick data for the dates that are missing trades and then running the optimization again to test.

                Thanks in advance; I look forward to assisting you further.
                Kate W.NinjaTrader Customer Service

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by mjairg, 07-20-2023, 11:57 PM
                3 responses
                213 views
                1 like
                Last Post PaulMohn  
                Started by TheWhiteDragon, 01-21-2019, 12:44 PM
                4 responses
                544 views
                0 likes
                Last Post PaulMohn  
                Started by GLFX005, Today, 03:23 AM
                0 responses
                3 views
                0 likes
                Last Post GLFX005
                by GLFX005
                 
                Started by XXtrader, Yesterday, 11:30 PM
                2 responses
                12 views
                0 likes
                Last Post XXtrader  
                Started by Waxavi, Today, 02:10 AM
                0 responses
                7 views
                0 likes
                Last Post Waxavi
                by Waxavi
                 
                Working...
                X