Compute and draw the moving average of a given time series
M=movav(x [,m1 [,m2 [,...]]]);
On the data "x" the function compute the moving averages of length m1, m2, and so on. Finally it draws the data "x" and all the moving averages.
First we generate 1000 log-normally distributed daily asset prices with 0.1/250 mean and 0.2/sqrt(250) variance. The first price of the asset is 25 euros.
-->M=grand(1000,1,'nor',0.1/250,0.2/sqrt(250));
-->price=exp(cumsum(M,1))*25;
Now we can use the function for computing the moving averages at 10 days and 30 days
-->M=movav(price,10,30);
The graph shows the historical data and both moving averages.
Francesco Menoncin - Brescia University - 2010