/// <summary> /// The Bollinger Bands® Percentage B is a technical indicator based upon the Bollinger Bands® study; it plots a histogram showing position of price relative to the bands. It is calculated as percentage ratio of two differences: first one is the difference between the price and the lower band value, second one is the difference between values of upper and lower bands. /// </summary> /// <returns></returns> public Indicator.BollingerPercentB BollingerPercentB(Data.IDataSeries input, BollingerPercentB_MATypes averageType, double numStdDev, int period) { if (InInitialize && input == null) { throw new ArgumentException("You only can access an indicator with the default input/bar series from within the 'Initialize()' method"); } return(_indicator.BollingerPercentB(input, averageType, numStdDev, period)); }
/// <summary> /// The Bollinger Bands® Percentage B is a technical indicator based upon the Bollinger Bands® study; it plots a histogram showing position of price relative to the bands. It is calculated as percentage ratio of two differences: first one is the difference between the price and the lower band value, second one is the difference between values of upper and lower bands. /// </summary> /// <returns></returns> public BollingerPercentB BollingerPercentB(Data.IDataSeries input, BollingerPercentB_MATypes averageType, double numStdDev, int period) { if (cacheBollingerPercentB != null) { for (int idx = 0; idx < cacheBollingerPercentB.Length; idx++) { if (cacheBollingerPercentB[idx].AverageType == averageType && Math.Abs(cacheBollingerPercentB[idx].NumStdDev - numStdDev) <= double.Epsilon && cacheBollingerPercentB[idx].Period == period && cacheBollingerPercentB[idx].EqualsInput(input)) { return(cacheBollingerPercentB[idx]); } } } lock (checkBollingerPercentB) { checkBollingerPercentB.AverageType = averageType; averageType = checkBollingerPercentB.AverageType; checkBollingerPercentB.NumStdDev = numStdDev; numStdDev = checkBollingerPercentB.NumStdDev; checkBollingerPercentB.Period = period; period = checkBollingerPercentB.Period; if (cacheBollingerPercentB != null) { for (int idx = 0; idx < cacheBollingerPercentB.Length; idx++) { if (cacheBollingerPercentB[idx].AverageType == averageType && Math.Abs(cacheBollingerPercentB[idx].NumStdDev - numStdDev) <= double.Epsilon && cacheBollingerPercentB[idx].Period == period && cacheBollingerPercentB[idx].EqualsInput(input)) { return(cacheBollingerPercentB[idx]); } } } BollingerPercentB indicator = new BollingerPercentB(); indicator.BarsRequired = BarsRequired; indicator.CalculateOnBarClose = CalculateOnBarClose; #if NT7 indicator.ForceMaximumBarsLookBack256 = ForceMaximumBarsLookBack256; indicator.MaximumBarsLookBack = MaximumBarsLookBack; #endif indicator.Input = input; indicator.AverageType = averageType; indicator.NumStdDev = numStdDev; indicator.Period = period; Indicators.Add(indicator); indicator.SetUp(); BollingerPercentB[] tmp = new BollingerPercentB[cacheBollingerPercentB == null ? 1 : cacheBollingerPercentB.Length + 1]; if (cacheBollingerPercentB != null) { cacheBollingerPercentB.CopyTo(tmp, 0); } tmp[tmp.Length - 1] = indicator; cacheBollingerPercentB = tmp; return(indicator); } }
public Indicator.BollingerPercentB BollingerPercentB(BollingerPercentB_MATypes averageType, double numStdDev, int period) { return(_indicator.BollingerPercentB(Input, averageType, numStdDev, period)); }