this
Description
The Bollinger Bands were introduced by J. Bollinger. They provide a visual channel of upper and lower bounds that prices tend to stay between. The channel calculation is based on variation about a statistical mean over a certain lookback period. The channels are defined by the calculation of the standard deviation (sigma) of the input value. The upper band is some multiplication factor of Sigma added to a simple moving average of the input value for the same period as the Sigma calculation. The lower band is the value minus Sigma times a multiplication factor. The SMA is plotted as a dashed line and the upper and lower Bollinger Bands are plotted as thin, solid lines. A text note is added to the plot in the upper left corner showing the lookback period and the upper and lower Bollinger Band Values.



Bollinger Bands bring statistics into the problem of determining stock trading ranges and extremes. Standard deviation can be used to determine when a price move is statistically out of the ordinary. Using a multiplication factor of 2 means that approximately 95% of the time price should remain between the Bollinger Bands. The distance between the upper and lower bands is also an indication of the volatility of the issue. Usually when the bands tighten a relatively substantial price move is pending.

Inputs
val
is the input data to used to calculate and construct the upper and lower bands. Closing prices are usually used.

p0 is the lookback period for the channel calculation.

xs is the multiplication factor to multiply Sigma by. As the number gets larger, more of the data series will fall between the bands.

color is normally defined in the plot script program that plots the overlay. EAS colors are designed to rotate through several predefined colors so that if several overlays are plotted on the price chart, they may be discerned from one another. The colors must be input as a character matrix and must be chosen from the set of standard O-Matrix colors.

thk is the thickness of the band lines. This parameter is also normally set in the plot script program that plots the overlay. Valid O-Matrix thicknesses are odd numbers.

Output Data & Plotting
returnflag
and plotflag are character inputs that tell fbollinger to alternately return data or plot the overlay on the Overlay Pallette. The returned data is a L-row x 2-column matrix, where L is the row dimension of the input data matrix, val. The first column is the lower band values and the second column is the upper band values.