private PlotCollection getLowPoints(PlotCollection data, int nLevel, int nLookahead) { if (data == null || data.Count < 3) { return(null); } PlotCollection dataLow = new PlotCollection(data.Name + " L" + nLevel.ToString()); int nOpen = data[0].PrimaryIndexY; int nHigh = data[0].PrimaryIndexY; int nLow = data[0].PrimaryIndexY; int nClose = data[0].PrimaryIndexY; if (data[0].Y_values.Length == 4) { nHigh = 1; nLow = 2; nClose = 3; } List <Tuple <int, Plot> > rgActive = new List <Tuple <int, Plot> >(); for (int i = 0; i < data.Count - nLookahead; i++) { if (data[i].Active) { rgActive.Add(new Tuple <int, Plot>(i, data[i])); } } if (rgActive.Count < 3) { return(null); } MinMax minmax = new MinMax(); int nIdx = 1; for (int i = 0; i < data.Count; i++) { int nIdxCurrent = rgActive[nIdx].Item1; if (i == nIdxCurrent && nIdx < rgActive.Count - 1) { Plot plotCurrent = data[nIdxCurrent]; int nIdxPast = rgActive[nIdx - 1].Item1; Plot plotPast = data[nIdxPast]; int nIdxFuture = rgActive[nIdx + 1].Item1; Plot plotFuture = data[nIdxFuture]; double dfOpen = (plotCurrent.Y_values.Length == 1) ? plotCurrent.Y : plotCurrent.Y_values[nOpen]; double dfClose = (plotCurrent.Y_values.Length == 1) ? plotCurrent.Y : plotCurrent.Y_values[nClose]; double dfHigh1 = (plotCurrent.Y_values.Length == 1) ? plotCurrent.Y : plotCurrent.Y_values[nHigh]; double dfLow1 = (plotCurrent.Y_values.Length == 1) ? plotCurrent.Y : plotCurrent.Y_values[nLow]; double dfHigh0 = (plotPast.Y_values.Length == 1) ? plotPast.Y : plotPast.Y_values[nHigh]; double dfLow0 = (plotPast.Y_values.Length == 1) ? plotPast.Y : plotPast.Y_values[nLow]; double dfHigh2 = (plotFuture.Y_values.Length == 1) ? plotFuture.Y : plotFuture.Y_values[nHigh]; double dfLow2 = (plotFuture.Y_values.Length == 1) ? plotFuture.Y : plotFuture.Y_values[nLow]; bool bLow = false; if (dfLow1 < dfLow0 && dfLow1 < dfLow2) { bLow = true; } minmax.Add(dfLow1); dataLow.Add(new Plot(data[nIdxCurrent].X, dfLow1, null, bLow, data[nIdxCurrent].Index)); nIdx++; } else { double dfLow = (data[i].Y_values.Length == 1) ? data[i].Y : data[i].Y_values[nLow]; dataLow.Add(new Plot(data[i].X, dfLow, null, false, data[i].Index)); } } dataLow.SetMinMax(minmax); return(dataLow); }