/// <summary> /// Get the last crossover for the given barNo /// </summary> /// <param name="barNo"></param> /// <returns>the number of bars ago for last crossover</returns> public int GetLastCrossover(Series <int> crossover, int barNo, LineCrossType crsType, BarIndexType barIdxType) { int crsov = -1; for (int i = 1; i < barNo - BarsRequiredToPlot - 1; i++) { if ((crossover[i] > 0 && crsType == LineCrossType.Above) || (crossover[i] < 0 && crsType == LineCrossType.Below) || (crossover[i] != 0 && crsType == LineCrossType.Both)) { crsov = i; } } if (barIdxType == BarIndexType.BarNO) { crsov = CurrentBar - crsov; } return(crsov); }
/// <summary> /// Get the last inflection for the given barNo /// </summary> /// <param name="barNo"></param> /// <returns>the number of bars ago/barNo for last inflection</returns> public int GetLastInflection(Series <int> inflection, int barNo, TrendDirection dir, BarIndexType barIdxType) { int inft = -1; for (int i = 1; i < barNo - BarsRequiredToPlot - 1; i++) { if ((inflection[i] < 0 && dir == TrendDirection.Down) || (inflection[i] > 0 && dir == TrendDirection.Up)) { inft = i; } if (barNo >= Input.Count) { Print("inflection[" + i + "]=" + inflection[i] + ", inft=" + inft); } } if (inft > 0 && barIdxType == BarIndexType.BarNO) { inft = CurrentBar - inft; } //Print("GetLastInflection barNo, currentBar, inft=" + barNo + "," + CurrentBar + "," + inft); return(inft); }