Given a moving average on the historical prices of an asset, the function creates two figures: in the first both the historical prices and the Bollinger bands (i.e. the moving average +/- "a" times the price standard deviation) are shown, in the second the so-called b-percentage is shown
bollinger (prices, m, a)
Function which creates two graphs: one with the Bollinger bands and one with the b-percentage index
column vector containing the historical prices of an asset
the lenght (in days if "prices" contains daily values) of the moving average which the bands are based on
First we generate 1000 log-normally distributed prices for an asset whose initial values is 25 euros. First step is the creation of 1000 normal random variables (with mean 0.1/250 and standard deviation 0.2/sqrt(250))
-->M=grand(1000,1,'nor',0.1/250,0.2/sqrt(250));Then we create the prices
-->prices=exp(cumsum(M,1))*25
and apply the function with m=100 days and a=2.5 times:
-->bollinger(prices,100,2.5)
Francesco Menoncin - Brescia University - 2010