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.


Leading and lagging moving averages chart


[Short,Long] = movavg(Asset,Lead,Lag,Alpha)



Security data, a vector of time-series prices.


Number of samples to use in leading average calculation. A positive integer. Lead must be less than or equal to Lag.


Number of samples to use in the lagging average calculation. A positive integer.


(Optional) Control parameter that determines the type of moving averages. 0 = simple moving average (default), 0.5 = square root weighted moving average, 1 = linear moving average, 2 = square weighted moving average, and so on. To calculate the exponential moving average, set Alpha ='e'.


When Alpha = 'e', the value of the moving average depends on all previous data points (due to the iterative calculation). In this case, the Lead and Lag parameters are used to calculate the weighting factor for their respective averages (which is different from the number of samples).


movavg(Asset,Lead,Lag,Alpha) plots leading and lagging moving averages.

[Short,Long] = movavg(Asset,Lead,Lag,Alpha) returns the leading Short and lagging Long moving average data without plotting it.


When using movavg syntax with output arguments, zero padding is used at the edges of the data. If you use movavg without output arguments, there is no zero padding in the data for the plot.


collapse all

Load the DIS closing prices using disney.mat.

load disney.mat

Use movavg to plot the leading and lagging moving averages for DIS.

legend('Asset Price','Lagging Long','Leading Short')

Introduced before R2006a

Was this topic helpful?