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 Mindset, 04-21-2026, 06:46 AM
      0 responses
      57 views
      0 likes
      Last Post Mindset
      by Mindset
       
      Started by M4ndoo, 04-20-2026, 05:21 PM
      0 responses
      78 views
      0 likes
      Last Post M4ndoo
      by M4ndoo
       
      Started by M4ndoo, 04-19-2026, 05:54 PM
      0 responses
      39 views
      0 likes
      Last Post M4ndoo
      by M4ndoo
       
      Started by cmoran13, 04-16-2026, 01:02 PM
      0 responses
      101 views
      0 likes
      Last Post cmoran13  
      Started by PaulMohn, 04-10-2026, 11:11 AM
      0 responses
      61 views
      0 likes
      Last Post PaulMohn  
      Working...
      X