Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Number of days to load versus testing

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

    Number of days to load versus testing

    Hello,

    I have a bit of an issue with the backtesting of my system. Let me try to explain.

    Basically I would like to backtest a specific date / set of days. But in my script I use, for example, let's say a 200 day simple moving average. This would require ofcourse to load a minimum of 200 days. In my backtesting input parameters I then would have to set the start-date to today-200 days in order to get a correct 200SMA value.

    Because if I backtest on, let's say only 5 days, then I dont get the correct 200SMA value.

    But this would also mean that the results of the backtest are based on that 200 days of trading! I don't want this. Basically I would like to load the 200 days of data but would like to select a specific date-range to test on.

    Is this possible?

    So if I would like to test from March 1st to March 5th, then the load results should be at least 200 days (for the 200SMA) from March 1st back + the 5 days to March 5th.

    Hope to hear from you.

    Thanks.

    #2
    Hi siroki, that would be possible by coding in a custon date filter in your conditions for example, so only trades could be taken in your test period chosen, which would be separate from the chart loading period. It's like a time filter for trading hours, but expanded for dates.

    You can for example create yourself 2 integer inputs for the start / end date to use in the filter and then use ToDay for the comparison - http://www.ninjatrader.com/support/h...lightsub=ToDay
    BertrandNinjaTrader Customer Service

    Comment


      #3
      Ofcourse, why didn't I think of that! Sometimes thinking of a solutions with the means at hand is less obvious. Thanks!

      What I did now is the following:

      Code:
      		private int iDateFrom;
      		private int iDateTo;
      
              protected override void OnBarUpdate()
              {
      			
      			if(ToDay(Time[0]) < iDateFrom || ToDay(Time[0]) > iDateTo) {
      				return;	
      			}
      
              ..... rest of my superprofitable supersecret code..... :p
      
              }
      
              #region Properties
      		public int DateFrom
      		{
      			get { return iDateFrom; }
      			set { 	if(value > ToDay(DateTime.Now)) { 
      						iDateFrom = ToDay(DateTime.Now);
      					} else { 
      						iDateFrom = value; 
      					} 
      				}
      		}
      		[Description("Enddate Active [yyyyMMdd]")]
      		[GridCategory("Parameters")]
      		public int DateTo
      		{
      			get { return iDateTo; }
      			set { 	if(value > ToDay(DateTime.Now)) { 
      						iDateTo = ToDay(DateTime.Now);
      					} else { 
      						iDateTo = value; 
      					} 
      				}
      		}			
              #endregion
      Thanks
      Last edited by siroki; 03-27-2014, 06:57 AM.

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by Jeremytang, 07-14-2018, 06:45 PM
      21 responses
      439 views
      0 likes
      Last Post mav8rick  
      Started by LeonK, Yesterday, 09:26 PM
      1 response
      8 views
      0 likes
      Last Post bltdavid  
      Started by NicholasJoannette, Yesterday, 03:01 PM
      2 responses
      11 views
      0 likes
      Last Post NicholasJoannette  
      Started by rach1994, Yesterday, 12:20 PM
      1 response
      35 views
      0 likes
      Last Post bltdavid  
      Started by litamm89, Yesterday, 11:00 AM
      5 responses
      22 views
      1 like
      Last Post rafael_delima86  
      Working...
      X