public void NewHigh(int bar, double price) { // If no low since last high and this high is higher, // the replace the last high point, else add it. if (highs.Count > 0 && lows.Count > 0 && lows[0].X < highs[0].X) { if (price > highs[0].Y) { // Make the replaced one Red. Chart.DrawBox(Color.Red, (int)highs[0].X, highs[0].Y); highs[0] = new ChartPoint(bar, price); } else { // Skip a lower high without a low in between. return; } } else { highs.Add(new ChartPoint(bar, price)); } Chart.DrawBox(Color.Blue, bar, price); if (highs.Count > 1 && lows.Count > 1) { try { ChartPoint point1 = highs[0]; ChartPoint point2 = FindPoint(lows, point1.X); ChartPoint point3 = FindPoint(highs, point2.X); if (point1.Y < point3.Y) { WideChannel wchannel = new WideChannel(Trend.Down, Bars); wchannel.Chart = Chart; wchannel.addHigh(point1.X); wchannel.addLow(point2.X); wchannel.addHigh(point3.X); wchannel.TryDraw(); channels.Add(wchannel); // Chart.DrawLine(Color.Red,highs[1].X,highs[1].Y,highs[0].X,highs[0].Y,LineStyle.Solid); } } catch (ApplicationException) { // Return if FindPoint failed. return; } } }
public WideChannel(WideChannel other) { this.bars = other.bars; lrHigh = new LinearRegression(other.lrHigh.Coord); lrLow = new LinearRegression(other.lrLow.Coord); }