Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Added series times in Strategy Analyzer

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

    Added series times in Strategy Analyzer

    Hi

    I am testing a strategy with an added bar series in the Strategy Analyzer and I have unexpected bar times (and other price data) for the added series.

    I would like to know what causes this behaviour so I can program accordingly.

    When the back test ends at today's date, the added bar series has the same date as the primary series. However, when ends earlier than "today", the test ends with the added series 1 day after the primary series, which is also 1 day after end of the back test.

    The is important because I write final data to file within OnTermination().

    Examples: If "today" is 11 May 2013 (New Zealand time)
    Back test to 11 May 2013 shows Time[0] = 11/05/2013 08:15:00 & Times[1][0] = 11/05/2013 08:15:00
    Back test to 10 May 2013 shows Time[0] = 10/05/2013 08:15:00 & Times[1][0] = 11/05/2013 08:15:00
    Back test to 9 May 2013 shows Time[0] = 9/05/2013 08:15:00 & Times[1][0] = 10/05/2013 08:15:00
    etc.

    Details:
    Primary series is ES 06-13, 1 minute, using a custom session template that starts 1 minute earlier than CME US Index Futures RTH (8:29 am Eastern Time), but ends at the same time (3:15 PM Eastern Time).
    The added series is SP500 Daily. I do not know what template is used for added series. The session template in the instrument settings is US Equities RTH. (Is this used?)
    My local time zone is New Zealand (GMT+12).
    In NZ time, the primary bar session starts 1:29 am & ends 8:15 am the day ahead of the Eastern Time session times, e.g. the market's Friday session starts at 1:29 am Saturday NZT.

    I have read this forum thread (http://www.ninjatrader.com/support/f...ad.php?t=57296), but I don't think it is the same issue because the session templates do not span more than one date.

    Regards
    Tony
    Last edited by Jellybean; 05-12-2013, 08:19 PM.

    #2
    Hi Tony, hope all is well - in which timezone is your custom session used setup? In your NZ time zone?

    For the session template logic for programmatically added series -

    'If a multi-series script adds an additional Bars object that already exists on the chart, the script will use the preexisting series instead of creating a new one to conserve memory. This includes that series' session template as applied from the chart. If the Bars object does not exist on the chart, the session template of the added Bars object will be the session template of the primary Bars object. If the primary Bars object is using the "<Use instrument settings>" session template then the additional Bars objects will use the default session templates as defined for their particular instruments in the Instrument Manager.'

    (http://www.ninjatrader.com/support/h...nstruments.htm)
    BertrandNinjaTrader Customer Service

    Comment


      #3
      Hi Bertrand

      The custom session template is defined in US Central Time - it is the same as CME US Index Futures RTH with the start time 1 min early.

      Thanks for clarification of the session template used for the added series. In this case, the strategy is run in the Control Center with the custom session specified, so the added Daily series will use the custom session template.

      I think the unexpected date for the added series is still not explained, right?

      Cheers

      Tony
      Last edited by Jellybean; 05-14-2013, 12:17 AM.

      Comment


        #4
        Hi Tony, I would expect this outcome if the custom session is used for your daily series, as the closing time would be in the future which is seen in the end of bar timestamp you receive in this setup. If you point to a session that would ensure the closing time is on the same day I would not expect this to surface.
        BertrandNinjaTrader Customer Service

        Comment


          #5
          Sorry Bertand, I still don't get it.

          The each trading session in the custom session template starts and ends on the same day, albeit the day ahead of the market day, so I think the Strategy Analyzer should take the daily bar of the same day as the 1 min series.

          I checked the time stamps of both series on charts. The timestamps for bars on the daily charts are the same as the last 1 min bar of the session (same date 08:15 am NZT). A daily chart using <Use instrument settings> session template has time stamps (same day 08:00 am NZT).

          Please see the attached output window and session template captures. I have more detailed explanation of my confusion there.

          I'm obviously mising something, but I don't understand why the final daily bar for a test with "To" = "Today" is the session just completed, whereas the final daily bar for a test with "To" = any date in the past is the day after the session just completed.

          I'v also attached a screenshot of the session template.

          Cheers
          Tony
          Attached Files
          Last edited by Jellybean; 05-14-2013, 07:31 PM.

          Comment


            #6
            Thanks Tony, lets take it a step back - would you see this as well if you set CalculateOnBarClose = false for the backtest? Otherwise you would not process the last bar in OnBarUpdate() since it never closed.
            BertrandNinjaTrader Customer Service

            Comment


              #7
              Hi Bertrand

              This was the clue I needed! If I set CalculateOnBarClose = true, the problem does not occur.

              However, it illustrates a confusion that may trap others.

              I have CalculateOnBarClose = false because I require operation every tick for live operation. When processing historical data I understand data is processed at the close of the bar. I assumed that all strategy analyzer operation would be as for historical data. However, this suggests that when the strategy terminates in a back test, access to bar data within OnTermination() is treated as live, not historical.

              Secondly, even though both the primary 1-min data and the added daily data bars end at exactly the same time (08:15 am NZT), the Strategy Analyzer appears to take the next daily sesssion as already started. I don't understand why this is. Perhaps the time that OnTermination() runs is later than the bar close time stamp(?).

              Anyway, I can now work on a solution.

              Thanks for your help.

              Cheers
              Tony
              Last edited by Jellybean; 05-15-2013, 09:16 PM.

              Comment


                #8
                Hi Tony, glad to hear. Correct the last bar in the backtest otherwise would not see any OnBarUpdate() event, as the opening tick of the next bar is not seen it would not have closed. As such the last processed bar in backtesting is the one before that - that's what you've ran into.

                The OnTermination() would be not tied to the bars time, so would run beyond your last bar timestamp here.
                BertrandNinjaTrader Customer Service

                Comment


                  #9
                  Hi Bertrand
                  Thanks for helping me with this learning experience!
                  Tony

                  Comment

                  Latest Posts

                  Collapse

                  Topics Statistics Last Post
                  Started by Rapine Heihei, Today, 08:19 PM
                  1 response
                  6 views
                  0 likes
                  Last Post NinjaTrader_Manfred  
                  Started by Rapine Heihei, Today, 08:25 PM
                  0 responses
                  5 views
                  0 likes
                  Last Post Rapine Heihei  
                  Started by f.saeidi, Today, 08:01 PM
                  1 response
                  4 views
                  0 likes
                  Last Post NinjaTrader_Manfred  
                  Started by Rapine Heihei, Today, 07:51 PM
                  0 responses
                  6 views
                  0 likes
                  Last Post Rapine Heihei  
                  Started by frslvr, 04-11-2024, 07:26 AM
                  5 responses
                  98 views
                  1 like
                  Last Post caryc123  
                  Working...
                  X