I am trying to create a Line indicator that will plot the Weekly ATR on any time frame chart. When doing that, I would like it to place based on the opening price of the current week and then delete all previous lines that were created. I would also like the line to extend across the entire chart.
Here is what I have created so far:
protected override void Initialize() { Add(new Plot(Color.FromKnownColor(KnownColor.Orange), PlotStyle.Line, "ATRHigh")); Add(new Plot(Color.FromKnownColor(KnownColor.Green), PlotStyle.Line, "ATRLow")); Add(PeriodType.Week, 1); Overlay = true; } /// <summary> /// Called on each bar update event (incoming tick) /// </summary> protected override void OnBarUpdate() { // Use this method for calculating your indicator values. Assign a value to each // plot below by replacing 'Close[0]' with your own formula. if (CurrentBars[0] <= BarsRequired || CurrentBars[1] <= BarsRequired) return; ATRHigh.Set(ATR(BarsArray[1],length)[0]+High[0]); ATRLow.Set(Low[0]-ATR(BarsArray[1],length)[0]); }
This posted code also leaves all previous ATR calulations on the chart (I would like the previous ones deleted)
The next change should be that the line should span the entire chart.
Thank you very much for your help!!
Comment