Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

How to apply Bars Array to higher time frame Open, High, Low, Close?

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

    How to apply Bars Array to higher time frame Open, High, Low, Close?

    This is what I have so far. It works fine on Daily chart. However, when I go down to a Tick chart, it used Tick values for the calculations.



    AddPlot(Brushes.Black, "MAColor0");
    AddPlot(Brushes.Black, "MAColor1");

    else if (State == State.Configure)
    {
    AddDataSeries(Data.BarsPeriodType.Day, 1);
    }
    }

    protected override void OnBarUpdate()
    {
    if(BehindBars == true)
    {
    // Make sure our object plots behind the chart bars
    SetZOrder(-1);
    }
    else if(BehindBars == false)
    {
    SetZOrder(BarsAdj);
    }

    if(CurrentBars[0] < BarsRequiredToPlot || CurrentBars[1] < BarsRequiredToPlot)
    return;

    double ATRMulti = ATR(BarsArray[1],ATR_Period)[0] * 2;

    MAColor0[0] = High[0] + ATRMulti;
    MAColor1[0] = Math.Abs(Low[0] - ATRMulti);
    }

    #2
    I think I figured it out. I am trying Highs[1][0], Lows[1][0]

    Comment


      #3
      Hello jamestrader21x,

      Thanks or your post.

      OnBarUpdate processes for all data series in the script. I.E. The Primary data series which we apply the script to, and any data series added with AddDataSeries.

      In the Tick case, you are processing the Tick data series and the Daily Data Series (because you added the Daily data series in State.Configure)

      PriceSeries references like High[0] and Low[0] reflect the current High and Low of the data series that is currently processing. You may check BarsInProgress to see which specific data series is updating. You may also use Highs[0][0] to reference the High of the primary data series and Highs[1][0] to reference the high of the first added data series.

      This is all detailed in our Multi Time Frame and Instruments documentation. Which is an important read for any NinjaScript developer writing a Multi Time Frame script.



      We look forward to assisting.

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by Geovanny Suaza, 02-11-2026, 06:32 PM
      0 responses
      566 views
      0 likes
      Last Post Geovanny Suaza  
      Started by Geovanny Suaza, 02-11-2026, 05:51 PM
      0 responses
      330 views
      1 like
      Last Post Geovanny Suaza  
      Started by Mindset, 02-09-2026, 11:44 AM
      0 responses
      101 views
      0 likes
      Last Post Mindset
      by Mindset
       
      Started by Geovanny Suaza, 02-02-2026, 12:30 PM
      0 responses
      547 views
      1 like
      Last Post Geovanny Suaza  
      Started by RFrosty, 01-28-2026, 06:49 PM
      0 responses
      548 views
      1 like
      Last Post RFrosty
      by RFrosty
       
      Working...
      X