/// <summary> /// This indicator returns 1 when we have n of consecutive bars down, otherwise returns 0. A down bar is defined as a bar where the close is below the open and the bars makes a lower high and a lower low. You can adjust the specific requirements with the indicator options. /// </summary> /// <returns></returns> public NBarsDown NBarsDown(Data.IDataSeries input, int barCount, bool barDown, bool lowerHigh, bool lowerLow) { if (cacheNBarsDown != null) { for (int idx = 0; idx < cacheNBarsDown.Length; idx++) { if (cacheNBarsDown[idx].BarCount == barCount && cacheNBarsDown[idx].BarDown == barDown && cacheNBarsDown[idx].LowerHigh == lowerHigh && cacheNBarsDown[idx].LowerLow == lowerLow && cacheNBarsDown[idx].EqualsInput(input)) { return(cacheNBarsDown[idx]); } } } lock (checkNBarsDown) { checkNBarsDown.BarCount = barCount; barCount = checkNBarsDown.BarCount; checkNBarsDown.BarDown = barDown; barDown = checkNBarsDown.BarDown; checkNBarsDown.LowerHigh = lowerHigh; lowerHigh = checkNBarsDown.LowerHigh; checkNBarsDown.LowerLow = lowerLow; lowerLow = checkNBarsDown.LowerLow; if (cacheNBarsDown != null) { for (int idx = 0; idx < cacheNBarsDown.Length; idx++) { if (cacheNBarsDown[idx].BarCount == barCount && cacheNBarsDown[idx].BarDown == barDown && cacheNBarsDown[idx].LowerHigh == lowerHigh && cacheNBarsDown[idx].LowerLow == lowerLow && cacheNBarsDown[idx].EqualsInput(input)) { return(cacheNBarsDown[idx]); } } } NBarsDown indicator = new NBarsDown(); indicator.BarsRequired = BarsRequired; indicator.CalculateOnBarClose = CalculateOnBarClose; #if NT7 indicator.ForceMaximumBarsLookBack256 = ForceMaximumBarsLookBack256; indicator.MaximumBarsLookBack = MaximumBarsLookBack; #endif indicator.Input = input; indicator.BarCount = barCount; indicator.BarDown = barDown; indicator.LowerHigh = lowerHigh; indicator.LowerLow = lowerLow; Indicators.Add(indicator); indicator.SetUp(); NBarsDown[] tmp = new NBarsDown[cacheNBarsDown == null ? 1 : cacheNBarsDown.Length + 1]; if (cacheNBarsDown != null) { cacheNBarsDown.CopyTo(tmp, 0); } tmp[tmp.Length - 1] = indicator; cacheNBarsDown = tmp; return(indicator); } }
/// <summary> /// This indicator returns 1 when we have n of consecutive bars down, otherwise returns 0. A down bar is defined as a bar where the close is below the open and the bars makes a lower high and a lower low. You can adjust the specific requirements with the indicator options. /// </summary> /// <returns></returns> public NBarsDown NBarsDown(Data.IDataSeries input, int barCount, bool barDown, bool lowerHigh, bool lowerLow) { if (cacheNBarsDown != null) for (int idx = 0; idx < cacheNBarsDown.Length; idx++) if (cacheNBarsDown[idx].BarCount == barCount && cacheNBarsDown[idx].BarDown == barDown && cacheNBarsDown[idx].LowerHigh == lowerHigh && cacheNBarsDown[idx].LowerLow == lowerLow && cacheNBarsDown[idx].EqualsInput(input)) return cacheNBarsDown[idx]; lock (checkNBarsDown) { checkNBarsDown.BarCount = barCount; barCount = checkNBarsDown.BarCount; checkNBarsDown.BarDown = barDown; barDown = checkNBarsDown.BarDown; checkNBarsDown.LowerHigh = lowerHigh; lowerHigh = checkNBarsDown.LowerHigh; checkNBarsDown.LowerLow = lowerLow; lowerLow = checkNBarsDown.LowerLow; if (cacheNBarsDown != null) for (int idx = 0; idx < cacheNBarsDown.Length; idx++) if (cacheNBarsDown[idx].BarCount == barCount && cacheNBarsDown[idx].BarDown == barDown && cacheNBarsDown[idx].LowerHigh == lowerHigh && cacheNBarsDown[idx].LowerLow == lowerLow && cacheNBarsDown[idx].EqualsInput(input)) return cacheNBarsDown[idx]; NBarsDown indicator = new NBarsDown(); indicator.BarsRequired = BarsRequired; indicator.CalculateOnBarClose = CalculateOnBarClose; #if NT7 indicator.ForceMaximumBarsLookBack256 = ForceMaximumBarsLookBack256; indicator.MaximumBarsLookBack = MaximumBarsLookBack; #endif indicator.Input = input; indicator.BarCount = barCount; indicator.BarDown = barDown; indicator.LowerHigh = lowerHigh; indicator.LowerLow = lowerLow; Indicators.Add(indicator); indicator.SetUp(); NBarsDown[] tmp = new NBarsDown[cacheNBarsDown == null ? 1 : cacheNBarsDown.Length + 1]; if (cacheNBarsDown != null) cacheNBarsDown.CopyTo(tmp, 0); tmp[tmp.Length - 1] = indicator; cacheNBarsDown = tmp; return indicator; } }