Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Multiple time frame issue

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

    Multiple time frame issue

    Hi, I'm testing a strategy that uses data from two time frames.

    I've added the time frames in the Initialize function

    Add(PeriodType.Day, 1);
    Add(PeriodType.Week, 1);

    In the OnBarUpdate function I have limited the strategy only to update bars only when there's a new daily bar:

    if (BarsInProgress != 1)
    return;

    My question is this. If I run my strategy and select "Day" as the data series type and "1" as the value why don't I get the same result if I change BarsInProgress to "!= 0"?

    Like this:

    if (BarsInProgress != 0)
    return;

    What is the difference between the two settings, when the backtest settings and the settings in the initialize function are the same?

    #2
    db8r,

    There are 3 bar objects based on the code you have provided.

    BarsInProgress 0 <-- primary bars as determined by the chart
    BarsInProgress 1 <-- your daily bars
    BarsInProgress 2 <-- your weekly bars

    Setting BarsInProgress != 0 means you will process BarsInProgress 1 and 2.
    Josh P.NinjaTrader Customer Service

    Comment


      #3
      Thanks for your swift reply. I'm not quite understanding why BarsInProgress 1 and 2 will be processed. What setting BarsInProgress to 0 is doing is getting all other settings than 0 to return (i.e. not be processed). Why would then BarsInProgress 1 and 2 be processed?

      Either way I think I've gotten my head around how I will test on multiple time frames and process only on daily bars. I will define daily bars in the Initialize function, set BarsInProgress to 1 and specify BarsArray[1] as data series in any indicators that I use. That seems to give me accurate results.

      Comment


        #4
        Right, I missed the "return" line you placed after the if-statement. Your analysis is correct.
        Josh P.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Geovanny Suaza, 02-11-2026, 06:32 PM
        0 responses
        656 views
        0 likes
        Last Post Geovanny Suaza  
        Started by Geovanny Suaza, 02-11-2026, 05:51 PM
        0 responses
        371 views
        1 like
        Last Post Geovanny Suaza  
        Started by Mindset, 02-09-2026, 11:44 AM
        0 responses
        109 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Started by Geovanny Suaza, 02-02-2026, 12:30 PM
        0 responses
        574 views
        1 like
        Last Post Geovanny Suaza  
        Started by RFrosty, 01-28-2026, 06:49 PM
        0 responses
        579 views
        1 like
        Last Post RFrosty
        by RFrosty
         
        Working...
        X