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 kinfxhk, 07-14-2026, 09:39 AM
    0 responses
    90 views
    0 likes
    Last Post kinfxhk
    by kinfxhk
     
    Started by kinfxhk, 07-13-2026, 10:18 AM
    0 responses
    92 views
    0 likes
    Last Post kinfxhk
    by kinfxhk
     
    Started by kinfxhk, 07-13-2026, 09:50 AM
    0 responses
    70 views
    0 likes
    Last Post kinfxhk
    by kinfxhk
     
    Started by kinfxhk, 07-13-2026, 07:21 AM
    0 responses
    87 views
    0 likes
    Last Post kinfxhk
    by kinfxhk
     
    Started by kinfxhk, 07-11-2026, 02:11 AM
    0 responses
    64 views
    0 likes
    Last Post kinfxhk
    by kinfxhk
     
    Working...
    X