public static DataArray<double> BollingerBandTop(StockSeriesData data, int periods, MovingAverageMethod method, double stddev) { if (data == null) { throw new ArgumentNullException("data", "Data must not be null."); } if (periods <= 0) { throw new ArgumentOutOfRangeException("periods", "Periods must not be negative or zero."); } if (stddev <= 0.0) { throw new ArgumentOutOfRangeException("stddev", "Standard deviation must not be negative or zero."); } DataArray<double> array = null; switch (method) { case MovingAverageMethod.Simple: array = SimpleMovingAverage(data, periods); break; case MovingAverageMethod.Weighted: array = WeightedMovingAverage(data, periods); break; case MovingAverageMethod.Exponential: array = ExponentialMovingAverage(data, periods); break; } DataArray<double> array2 = ChartMath.StdDev(data, periods); return ChartMath.Add(array, ChartMath.Multiply(array2, stddev)); }
public static DataArray <double> BollingerBandTop(StockSeriesData data, int periods, MovingAverageMethod method, double stddev) { if (data == null) { throw new ArgumentNullException("data", "Data must not be null."); } if (periods <= 0) { throw new ArgumentOutOfRangeException("periods", "Periods must not be negative or zero."); } if (stddev <= 0.0) { throw new ArgumentOutOfRangeException("stddev", "Standard deviation must not be negative or zero."); } DataArray <double> array = null; switch (method) { case MovingAverageMethod.Simple: array = SimpleMovingAverage(data, periods); break; case MovingAverageMethod.Weighted: array = WeightedMovingAverage(data, periods); break; case MovingAverageMethod.Exponential: array = ExponentialMovingAverage(data, periods); break; } DataArray <double> array2 = ChartMath.StdDev(data, periods); return(ChartMath.Add(array, ChartMath.Multiply(array2, stddev))); }