If you look at the code below you can see that it has several references to zigZagSeries1 but I need to pass the DataSeries in as an argument somehow so I can use the same code again without having to duplicate code. The problem is any time I change the parameters in 'public override void Plot' I get an error that reads:
Here's the code:
public override void Plot(Graphics graphics, Rectangle bounds, double min, double max) { if (Bars == null || ChartControl == null) return; // make sure indicator is calculated until last (existing) bar IsValidPlot(Bars.Count - 1 + (CalculateOnBarClose ? -1 : 0)); int preDiff = 1; for (int i = FirstBarIndexPainted - 1; i >= BarsRequired; i--) { if (i < 0 || (zigZagSeries1.IsValidPlot(i) && zigZagSeries1.Get(i) > 0)) break; preDiff++; } int postDiff = 0; for (int i = LastBarIndexPainted; i <= zigZagSeries1.Count; i++) { if (i < 0 || (zigZagSeries1.IsValidPlot(i) && zigZagSeries1.Get(i) > 0)) break; postDiff++; } bool linePlotted = false; using (GraphicsPath path = new GraphicsPath()) { int lastIdx = -1; double lastValue = -1; for (int idx = this.FirstBarIndexPainted - preDiff; idx <= this.LastBarIndexPainted + postDiff; idx++) { if (idx - Displacement < 0 || idx - Displacement >= Bars.Count || (!ChartControl.ShowBarsRequired && idx - Displacement < BarsRequired)) continue; if (!(zigZagSeries1.IsValidPlot(idx) && zigZagSeries1.Get(idx) > 0)) continue; if (lastValue >= 0) { int x0 = ChartControl.GetXByBarIdx(BarsArray[0], lastIdx); int x1 = ChartControl.GetXByBarIdx(BarsArray[0], idx); int y0 = ChartControl.GetYByValue(this, lastValue); int y1 = ChartControl.GetYByValue(this, zigZagSeries1.Get(idx)); path.AddLine(x0, y0, x1, y1); linePlotted = true; } // save as previous point lastIdx = idx; lastValue = zigZagSeries1.Get(idx); } SmoothingMode oldSmoothingMode = graphics.SmoothingMode; graphics.SmoothingMode = SmoothingMode.AntiAlias; graphics.DrawPath(Plots[0].Pen, path); graphics.SmoothingMode = oldSmoothingMode; } if (!linePlotted) DrawTextFixed("ZigZagErrorMsg", "aaaNiedZigZag can't plot any values since the deviation value is too large. Please reduce it.", TextPosition.BottomRight); }
Comment