movavg function lead and lag meaning

Hi, Could someone explaing to me what Lead and Lag represent please in the moving average. Usually when I deal with moving average it only consists of one variable which is the period (eg 20 day moving average)

Réponses (3)

Oleg Komarov
Oleg Komarov le 11 Fév 2011

0 votes

Looking at the code:

% compute general moving average (ie simple, linear, etc) 
% build weighting vectors 
i = 1:lag; 
wa(i) = (lag - i + 1).^alpha./sum([1:lag].^alpha); 
i = 1:lead; 
wb(i) = (lead - i + 1) .^alpha/sum([1:lead].^alpha); 
% build moving average vectors by filtering asset through weights 
a = filter(wa,1,asset); 
b = filter(wb,1,asset);

If you call:

[Short,Long]= movavg(A,20,20,1);

You get exaclty the same averages, I guess they tried to give emphasis to the fact that one is long run and the other is short run.

Anyway, the movavg implements the weighted moving average (linear and exponential):

Linear weights

Exponential weights

Oleg

Sean de Wolski
Sean de Wolski le 12 Avr 2011

0 votes

When you're replacing the value of a point with the mean of it and the next point; you get lead.
When you replace the value of a point with the mean of it and the previous point you get lag.
Sonima
Sonima le 23 Juil 2018

0 votes

Hi! If one assign both lag and lead to for instance 20, then Matlab will give the same result as when one set EMA20 is most of the charting software? AM I right?

Catégories

En savoir plus sur Mathematics and Optimization dans Centre d'aide et File Exchange

Question posée :

le 11 Fév 2011

Réponse apportée :

le 23 Juil 2018

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by