Main Content

bolling

Bollinger band chart

bollingis not recommended. Usebollingerinstead.

Syntax

bolling(Asset,Samples,Alpha,Width)[Movavgv,UpperBand,LowerBand] = bolling(Asset,Samples,Alpha,Width)

Arguments

Asset

Vector of asset data.

Samples

Number of samples to use in computing the moving average.

Alpha

(Optional) Exponent used to compute the element weights of the moving average. Default =0(simple moving average).

Width

(Optional) Number of standard deviations to include in the envelope. A multiplicative factor specifying how tight the bands should be around the simple moving average. Default =2.

Description

bolling(Asset,Samples,Alpha,Width)plots Bollinger bands for givenAssetdata. This form of the function does not return any data.

[Movavgv,UpperBand,LowerBand] = bolling(Asset,Samples,Alpha,Width)returnsMovavgvwith the moving average of theAssetdata,UpperBandwith the upper band data, andLowerBandwith the lower band data. This form of the function does not plot any data.

Note

The standard deviations are normalized byN-1, whereN= the sequence length.

Examples

IfAssetis a column vector of closing stock prices

bolling(Asset, 20, 1)

plots linear 20-day moving average Bollinger bands based on the stock prices.

[Movavgv, UpperBand, LowerBand] = bolling(Asset, 20, 1)

returnsMovavgv,UpperBand, andLowerBandas vectors containing the moving average, upper band, and lower band data, without plotting the data.

Version History

Introduced before R2006a