This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English version of the page.

Note: This page has been translated by MathWorks. Please click here
To view all translated materials including this page, select Japan from the country navigator on the bottom of this page.


Time series Bollinger band


[mid,uppr,lowr] = bollinger(data,wsize,wts,nstd)
[midfts,upprfts,lowrfts] = bollinger(tsobj,wsize,wts,nstd)



Data vector.


The input time series data must be ordered from newest to oldest.


(Optional) Window size. Default = 20.


(Optional) Weight factor. Determines the type of moving average used. Default = 0 (box). 1 = linear.


(Optional) Number of standard deviations for upper and lower bands. Default = 2.


Financial time series object.


[mid,uppr,lowr] = bollinger(data,wsize,wts,nstd) calculates the middle (mid), upper (uppr), and lower (lowr) bands that make up the Bollinger bands from the vector data.

mid is the vector that represents the middle band, a simple moving average with a window size of wsize. uppr and lowr are vectors that represent the upper and lower bands. uppr is a vector representing the upper band that is +nstd times. lowr is a vector representing the lower band that is -nstd times.

[midfts,upprfts,lowrfts] = bollinger(tsobj,wsize,wts,nstd) calculates the middle, upper, and lower bands that make up the Bollinger bands from a financial time series object tsobj.

midfts is a financial time series object that represents the middle band for all series in tsobj. Both upprfts and lowrfts are financial time series objects that represent the upper and lower bands of all series, which are +nstd times and -nstd times moving standard deviations away from the middle band.


collapse all

This example shows how to compute the Bollinger bands for Disney stock closing prices and plot the results.

load disney.mat
[dis_Mid,dis_Uppr,dis_Lowr]= bollinger(dis);
dis_CloseBolling = [dis_Mid.CLOSE, dis_Uppr.CLOSE,... 
title('Bollinger Bands for Disney Closing Prices')


Achelis, Steven B. Technical Analysis from A to Z. Second Edition. McGraw-Hill, 1995, pp. 72–74.

Introduced before R2006a

Was this topic helpful?