Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Session templates and holidays

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

    Session templates and holidays

    Maybe after a wild day today not the best moment, but:


    Currently SessionTemplates define the behaviour of the ExitOnClose and ExitOnCloseSeconds strategy parameters.

    This is all fine but the behaviour of the strategy dipends then on the correct parameters of the Session template in use.
    Example: Lets assume a SessionTemplate for Dax has by Error set the CloseTime to 22:15. Since the exchange closes at 22:00 the ExitOnClose ill not be executed if ExitOnCloseSeconds is less then 15*60.

    So far so good. Just e have to know...

    How about holidays: Example Martin Luther King Day.
    The ES closed early @ 19:00 MEZ and not at 22:15 as usual because of the holiday.

    How can I incorporate a Holiday managment in the session templates?
    I would like to have a the current days template adjusted for an eventual holiday. How can I achieve this?
    ( I have all the standard holiday functions like Christian, Eurex- and US Holidays, but how to incorporate into ...)

    Any tipps from Ninja (allthough I expect the usual answer)

    regards
    Andreas

    #2
    Andreas,

    NinjaTrader does not have a holiday management system. You will have to hard code logic into your strategy to handle those holiday dates or you would have to create a new session template that actually gets you the proper end dates you want for that day of week. Say a holiday lands on Monday, you would have to create yourself a temporary session template that adjusts for this and apply your strategy with this session template. Note that this technique will cause historical data to be reflective of this session template too. If your strategy requires lots of old data to calculate correctly, the first suggestion would be the way to go.
    Josh P.NinjaTrader Customer Service

    Comment


      #3
      When backtesting, it's important to deal with holidays and short trading days because they can distort the results - you can even wind up with the optimizer fitting your parameters to include trades outside of regular trading hours that you would never have made in real life. This is because some instruments will have low-volume ticks outside of regular hours (i.e. futures, or after-hours stocks).

      The NT7 long-term wish list should include a way of dealing with holidays and short trading days. In fact, what you really should want is a centralized way of pushing out calendars, and some maybe sort of wiki to let users edit them.

      In the meantime, here are the routines I use for checking for holidays and short trading days. I just exclude these days from trading, although you could include short trading days by subtracting 3 hours from the regular session close. You can pass them either a DateTime or the result of ToDay(DateTime) and they will return true if a holiday or short trading day. They of course need to be edited in the future to stay current, or to add more historical dates if you backtest for dates in 2004 or earlier.


      Code:
      #region NYSE Holidays
      		private static bool NYSEShortTradingDay(DateTime dt)
      		{
      			return NYSEShortTradingDay(dt.Year * 10000 + dt.Month * 100 + dt.Day);
      		}
      		
      		private static bool NYSEShortTradingDay(int d)
      		{
      			switch (d)
      			{
      				case 20051125:		// Nov 25, 2005
      				case 20060703:		// July 3, 2006
      				case 20061124:		// Nov 24, 2006
      				case 20070703:		// July 3, 2007
      				case 20071123:		// Nov 23, 2007
      				case 20071224:		// Dec 24, 2007
      				case 20080703:		// July 3, 2008
      				case 20081128:		// Nov 28, 2008
      				case 20081224:		// Dec 24, 2008
      				case 20091127:		// Nov 27, 2009
      				case 20091224:		// Dec 24, 2009
      				case 20101126:		// Nov 26, 2010
      				case 20111125:		// Nov 25, 2011
      					return true;
      				default:
      					return false;
      			}
      		}
      		
      		private static bool NYSEHoliday(DateTime dt)
      		{
      			return NYSEHoliday(dt.Year * 10000 + dt.Month * 100 + dt.Day);
      		}
      		
      		private static bool NYSEHoliday(int d)
      		{
      			switch (d)
      			{
      				case 20050101:		// Jan 1, 2005
      				case 20050117:		// Jan 17, 2005
      				case 20050221:		// Feb 21, 2005
      				case 20050325:		// Mar 25, 2005
      				case 20050530:		// Jan 30, 2005
      				case 20050704:		// July 4, 2005
      				case 20050905:		// Sept 5, 2005
      				case 20051124:		// Nov 24, 2005
      				case 20051226:		// Dec 26, 2005
      				case 20060102:		// Jan 2, 2006
      				case 20060116:		// Jan 16, 2006
      				case 20060220:		// Feb 20, 2006
      				case 20060414:		// Apr 14, 2006
      				case 20060529:		// May 29, 2006
      				case 20060704:		// July 4, 2006
      				case 20060904:		// Sept 4, 2006
      				case 20061123:		// Nov 23, 2006
      				case 20061225:		// Dec 25, 2006
      				case 20070101:		// Jan 1, 2007
      				case 20070115:		// Jan 15, 2007
      				case 20070219:		// Feb 19, 2007
      				case 20070406:		// Apr 6, 2007
      				case 20070528:		// May 28, 2007
      				case 20070704:		// July 4, 2007
      				case 20070903:		// Sept 3, 2007
      				case 20071122:		// Nov 22, 2007
      				case 20071225:		// Dec 25, 2007
      				case 20080101:		// Jan 1, 2008
      				case 20080121:		// Jan 21, 2008
      				case 20080218:		// Feb 18, 2008
      				case 20080321:		// Mar 21, 2008
      				case 20080526:		// May 26, 2008
      				case 20080704:		// July 4, 2008
      				case 20080901:		// Sept 1, 2008
      				case 20081127:		// Nov 27, 2008
      				case 20081225:		// Dec 25, 2008
      				case 20090101:		// Jan 1, 2009
      				case 20090119:		// Jan 19, 2009
      				case 20090216:		// Feb 16, 2009
      				case 20090410:		// Apr 10, 2009
      				case 20090525:		// May 25, 2009
      				case 20090703:		// Jan 3, 2009
      				case 20090907:		// Sept 7, 2009
      				case 20091126:		// Nov 26, 2009
      				case 20091225:		// Dec 25, 2009
      				case 20100101:		// Jan 1, 2010
      				case 20100118:		// Jan 18, 2010
      				case 20100215:		// Feb 15, 2010
      				case 20100402:		// Apr 2, 2010
      				case 20100531:		// May 31, 2010
      				case 20100705:		// July 5, 2010
      				case 20100906:		// Sept 6, 2010
      				case 20101125:		// Nov 25, 2010
      				case 20101225:		// Dec 24, 2010
      				case 20110117:		// Jan 17, 2011
      				case 20110221:		// Feb 21, 2011
      				case 20110422:		// Apr 22, 2011
      				case 20110530:		// May 30, 2011
      				case 20110704:		// July 4, 2011
      				case 20110905:		// Sept 5, 2011
      				case 20111124:		// Nov 24, 2011
      				case 20111226:		// Dec 26, 2011
      					return true;
      					
      				default:
      					return false;
      			}
      		}
      		#endregion

      Comment


        #4
        kdoren, thank you very much for sharing and also for voicing your thoughts on this topic, we've added this already to our list for the future.
        BertrandNinjaTrader Customer Service

        Comment


          #5
          Just wanted to follow up on this - has an 'official' feature made it into the latest release?

          Comment


            #6
            Also, a related question: How do I pass in the 'current date' into the work around methods posted. If I just get the current date via 'new Date()' then it won't work for back testing. What I need is the date of that particular session.

            Any help appreciated.

            UPDATE: I think I figured it out - I'm currently using Time[0] - if that's a bad idea please let me know.
            Last edited by molecool; 08-26-2010, 07:35 PM.

            Comment


              #7
              molecool, Time[0] as the current bar's timestamp should do it, yes - the holiday feature in on our feedback list - we're currently working on stabilizing NT7 beta to make it ready for production.
              BertrandNinjaTrader Customer Service

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by Segwin, 05-07-2018, 02:15 PM
              14 responses
              1,789 views
              0 likes
              Last Post aligator  
              Started by Jimmyk, 01-26-2018, 05:19 AM
              6 responses
              837 views
              0 likes
              Last Post emuns
              by emuns
               
              Started by jxs_xrj, 01-12-2020, 09:49 AM
              6 responses
              3,293 views
              1 like
              Last Post jgualdronc  
              Started by Touch-Ups, Today, 10:36 AM
              0 responses
              13 views
              0 likes
              Last Post Touch-Ups  
              Started by geddyisodin, 04-25-2024, 05:20 AM
              11 responses
              63 views
              0 likes
              Last Post halgo_boulder  
              Working...
              X