File Exchange

image thumbnail

EWMA St.Dev.

version (1.24 KB) by Lorenzo Brancali
This code calculates the Exponentially Weighted Moving Average Standard Deviation


Updated 09 Mar 2012

View License

Exponentially weighted moving average (EWMA) standard deviation applies different weights to different returns. More recent returns have greater weight on the variance. The exponentially weighted moving average (EWMA) introduces lambda, called the smoothing parameter. Lambda must be less than one.

Cite As

Lorenzo Brancali (2020). EWMA St.Dev. (, MATLAB Central File Exchange. Retrieved .

Comments and Ratings (6)

Lautaro Parada

Vladimir Yanovskiy

Marvellous function

Lautaro Parada


Sorry, because it is not a note written in English, it is impossible to understand.


Correct me if I am wrong but this code appears to have an error.


Assume d = 0.94. When i = 1, which corresponds to the most recent observation, d^i-1 = 1.0. The product of d^i-1*(1-d) which yields 0.06 should be applied to the squared return (subtract mean zero) of the most recet observation. However, with X(t-1, :) in your formula above, d^i-1*(1-d) for i = 1 is in fact applied to the next most recent observation.

Perhaps my explanation is not very clear but fundamentally when you supply say 20 returns to the formula, you shouldnt compute against 20-1 observations.

Juan Pablo Hernandez

MATLAB Release Compatibility
Created with R2008a
Compatible with any release
Platform Compatibility
Windows macOS Linux