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 CarlTrading, 03-31-2026, 09:41 PM
      1 response
      43 views
      0 likes
      Last Post NinjaTrader_ChelseaB  
      Started by CarlTrading, 04-01-2026, 02:41 AM
      0 responses
      21 views
      0 likes
      Last Post CarlTrading  
      Started by CaptainJack, 03-31-2026, 11:44 PM
      0 responses
      30 views
      1 like
      Last Post CaptainJack  
      Started by CarlTrading, 03-30-2026, 11:51 AM
      0 responses
      50 views
      0 likes
      Last Post CarlTrading  
      Started by CarlTrading, 03-30-2026, 11:48 AM
      0 responses
      40 views
      0 likes
      Last Post CarlTrading  
      Working...
      X