Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Backtest Specific Dates

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

    Backtest Specific Dates

    Hi All,

    Is there a way to code NinjaTrader to backtest only specific dates? I've been able to accomplish my goal, but in a very newbie way (see code below).

    //Dates to be backtested
    private DateTime date1 = new DateTime(2008, 7, 19);
    private DateTime date2 = new DateTime(2008, 12, 19);
    And on and on with the other dates...

    //Entry condition
    if (Time[0].Date == date1.Date)
    EnterPosition();

    if (Time[0].Date == date2.Date)
    EnterPosition();
    And on and on with the other dates...

    Is there a more efficient way to do the same? I understand that I have to manually declare the dates, so that portion will probably not change. But the entry condition might be simplified in some way. I've tried to use string concatenation to change the "date1" variable to "date2" after the first date is executed, but without any luck.

    As always, thank you all for your help.
    Last edited by GeoOrtiz; 02-12-2013, 10:32 AM.

    #2
    Hello GeoOrtiz,

    The only other ways that I can think of to do something like that would be to either setup a user defined variable(s) for the dates or you can specify the Time Frame directly inside of the Strategy Analyzer under the Time frame option.
    JCNinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by CortexZenUSA, Today, 12:53 AM
    0 responses
    1 view
    0 likes
    Last Post CortexZenUSA  
    Started by CortexZenUSA, Today, 12:46 AM
    0 responses
    1 view
    0 likes
    Last Post CortexZenUSA  
    Started by usazencortex, Today, 12:43 AM
    0 responses
    5 views
    0 likes
    Last Post usazencortex  
    Started by sidlercom80, 10-28-2023, 08:49 AM
    168 responses
    2,266 views
    0 likes
    Last Post sidlercom80  
    Started by Barry Milan, Yesterday, 10:35 PM
    3 responses
    13 views
    0 likes
    Last Post NinjaTrader_Manfred  
    Working...
    X