WebCab Technical Analysis
(J2SE Edition)

webcab.lib.finance.trading.indicators
Class BollingerBands

java.lang.Object
  |
  +--webcab.lib.finance.trading.indicators.BollingerBands
All Implemented Interfaces:
Serializable

public class BollingerBands
extends Object
implements Serializable

Within this class we offer procedures which evaluate the upper and lower Bollinger Bands.

Bollinger Bands are a type of envelope that are plotted at standard deviation levels above and below the corresponding moving average. This produces an effect of having the bands widen during periods of higher volatility and contract during less volatile periods. Bollinger Bands indicate the relative supply and demand for a given asset. If the asset to move close to the top of the envelope then it indicates that there is strong demand for the asset, conversely if the asset hugs the bottom of the trading range then it indicates that there is oversupply of the asset.

Since the Bollinger Bands will nearly always be combined with other indicators when forming a trading system the number of periods used in the evaluation of the standard deviation of the stocks and the moving average will vary. For those without design restrictions a popular choice of the number of time periods is around 20-23.

See Also:
Serialized Form

Constructor Summary
BollingerBands()
          Creates a new instance.
 
Method Summary
 double bollingerBandsHigher(double[] historicalPrices, double standardDeviationLevel)
          Evaluates the position of the Upper Bollinger Band for a given standard deviation level.
 double bollingerBandsLower(double[] historicalPrices, double standardDeviationLevel)
          Evaluates the position of the Lower Bollinger Band for a given standard deviation level.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BollingerBands

public BollingerBands()
Creates a new instance.

Method Detail

bollingerBandsLower

public double bollingerBandsLower(double[] historicalPrices,
                                  double standardDeviationLevel)
Evaluates the position of the Lower Bollinger Band for a given standard deviation level. Please note that by standard deviation level we not only refer to the number of standard deviations shifts away from the moving average at which the Higher Bollinger Band is drawn but also the number of time series points which are used in the evaluation of the standard deviation and the moving average.

Parameters:
historicalPrices - an array of doubles where the first term correspond the latest periods price and the previous element is the value of the element before that and so on... The length of this array is equal to the number of periods used in the evaluation of the standard deviation and the moving average.
standardDeviationLevel - the number of standard deviation which the lower band in shifted from the moving average
Throws:
IllegalArgumentException - thrown when the historicaPrices array in empty or the number of standard deviations considered (i.e. the parameters standardDeviationLevel) is not positive number.

bollingerBandsHigher

public double bollingerBandsHigher(double[] historicalPrices,
                                   double standardDeviationLevel)
Evaluates the position of the Upper Bollinger Band for a given standard deviation level. Please note that by standard deviation level we not only refer to the number of standard deviations shifts away from the moving average at which the Higher Bollinger Band is drawn but also the number of time series points which are used in the evaluation of the standard deviation and the moving average.

Parameters:
historicalPrices - an array of doubles where the first term correspond the latest periods price and the previous element is the value of the element before that and so on... The length of this array is equal to the number of periods used in the evaluation of the standard deviation.
standardDeviationLevel - the (positive) number of standard deviations which the lower band in shifted from the moving average.
Throws:
IllegalArgumentException - throw if the array historicalPrices is empty or if the number of standard deviations given (i.e. the parameter standardDeviationsLevel) is a negative number.

WebCab Technical Analysis
(J2SE Edition)