I have the below code that works well until I get to the last line, where I am trying to use the Time. I then get the error saying that "at bar 30, the bar index needs to be greater than 0"
What am I doing wrong? Is it wrong how I am applying the Time[] in the last line? The only thing I can figure is I am doing that wrongly. I already have filters in the beginning to make sure there are enough bars, etc.
Thanks for your assistance.
public class JSMissedPivotsv1 : Indicator { #region Variables // Wizard generated variables private int pivotValidFor = 6; // Default setting for PivotValidFor private int NumMPValidfor = 7; private int cnt = 0, TF=60, HrlineCnt=1, i = -1, ThisHour05, NextHour05, HrBeginShift, HrEndShift, TotalBars; private double p; private bool ArrayFull = false, PrevPivsBuffed = false, phit = false, DrawMissedPivotsOnly = true; private DateTime PrevHourTime, BarTime; private double[]HourMissedPivot; private DateTimeSeries[]HourMPTimeOpen; private DateTimeSeries[]HourMPTimeClosed; // User defined variables (add any user defined variables below) #endregion /// <summary> /// This method is used to configure the indicator and is called once before any bar data is loaded. /// </summary> protected override void Initialize() { Overlay = true; CalculateOnBarClose = true; //Add(PeriodType.Minute, 60); Add(new Plot(Color.FromKnownColor(KnownColor.Orange), PlotStyle.Line, "MissedPivot1")); Add(new Plot(Color.FromKnownColor(KnownColor.Peru), PlotStyle.Line, "MissedPivot2")); } /// <summary> /// Called on each bar update event (incoming tick) /// </summary> protected override void OnBarUpdate() { if (Bars.Count == 0) return; if (CurrentBar < (60/Bars.Period.Value) || CurrentBar > (Bars.Count-(60/Bars.Period.Value))) return; i = Bars.Count - CurrentBar; Print(Bars.Count+ " " + i + " " + CurrentBar); //At this point they are the same numbers //up until this point everything Print's correctly. Print(Time[i] + " " + Time[CurrentBar]);//this is where the error comes
Comment