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

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 bill2023, Yesterday, 08:51 AM
      8 responses
      43 views
      0 likes
      Last Post bill2023  
      Started by yertle, Today, 08:38 AM
      6 responses
      25 views
      0 likes
      Last Post ryjoga
      by ryjoga
       
      Started by algospoke, Yesterday, 06:40 PM
      2 responses
      24 views
      0 likes
      Last Post algospoke  
      Started by ghoul, Today, 06:02 PM
      3 responses
      16 views
      0 likes
      Last Post NinjaTrader_Manfred  
      Started by jeronymite, 04-12-2024, 04:26 PM
      3 responses
      46 views
      0 likes
      Last Post jeronymite  
      Working...
      X