I am trying to develop a very simple indicator. I'm trying to plot the close of daily data on an intraday chart. I'm trying to do this using the next code:
protected override void Initialize()
{
Add(new Plot(Color.FromKnownColor(KnownColor.OrangeRed), PlotStyle.Line, "Valor"));
Add(PeriodType.Day, 1);
Overlay = true;
}
protected override void OnBarUpdate()
{
if(CurrentBar < 15) return;
if (BarsInProgress == 0)
Valor.Set(Closes[1][0]);
}
I have enough bars on the daily chart, however when I try this code I receive the next message:
Error on calling 'OnBarUpdate' method for indicator 'X' on bar 15: You are accessing an index with a value that is invalid since its out of range. I.E. accessing a series [barsAgo] with a value of 5 when there are only 4 bars on the chart.
Please, could you tell me if there is any mistake on the code?
Thanks.
Comment