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 charlesugo_1, 05-26-2026, 05:03 PM
        0 responses
        60 views
        0 likes
        Last Post charlesugo_1  
        Started by DannyP96, 05-18-2026, 02:38 PM
        1 response
        145 views
        0 likes
        Last Post NinjaTrader_ChelseaB  
        Started by CarlTrading, 05-11-2026, 05:56 AM
        0 responses
        161 views
        0 likes
        Last Post CarlTrading  
        Started by CarlTrading, 05-10-2026, 08:12 PM
        0 responses
        97 views
        0 likes
        Last Post CarlTrading  
        Started by Hwop38, 05-04-2026, 07:02 PM
        0 responses
        283 views
        0 likes
        Last Post Hwop38
        by Hwop38
         
        Working...
        X