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 SalmaTrader, 07-07-2026, 10:26 PM
        0 responses
        47 views
        0 likes
        Last Post SalmaTrader  
        Started by CarlTrading, 07-05-2026, 01:16 PM
        0 responses
        22 views
        0 likes
        Last Post CarlTrading  
        Started by CaptainJack, 06-17-2026, 10:32 AM
        0 responses
        15 views
        0 likes
        Last Post CaptainJack  
        Started by kinfxhk, 06-17-2026, 04:15 AM
        0 responses
        21 views
        0 likes
        Last Post kinfxhk
        by kinfxhk
         
        Started by kinfxhk, 06-17-2026, 04:06 AM
        0 responses
        23 views
        0 likes
        Last Post kinfxhk
        by kinfxhk
         
        Working...
        X