A Deep Dive Into Moving Averages

October 13, 2021

Moving averages are inherent in the world of technical analysis and are present in the core calculations of many technical indicators. In this post, we take a deep dive into 3 types of moving averages used every day by traders: the Simple Moving Average ( SMA ), Exponential Moving Average ( EMA ) and the Weighted Moving Average ( WMA ).

Moving averages are inherent in the world of technical analysis and are present in the core calculations of many technical indicators. In this post, we take a deep dive into 3 types of moving averages used every day by traders: the Simple Moving Average ( SMA ), Exponential Moving Average ( EMA ) and the Weighted Moving Average ( WMA ).

The topics covered below can have practical applications while others are solely informative.


Moving averages are trend indicators commonly used to smooth the closing prices by removing or attenuating certain variations and are able to estimate underlying trends. Their usage can be recorded as early as 1829 by John Finlaison for smoothing mortality rates (1).

In technical analysis moving averages are often essential for traders and can be found in every technical analysis software. However, they are not specific to this field as they often appear in Time Series Analysis and Digital Signal Processing (DSP).

Moving averages possess a single user setting that generally determines the degree of smoothness. This setting is often referred to as the moving average "length", "period" or less commonly "window size".

Curiosities About The Simple Moving Average

The Simple Moving Average abbreviated to "SMA", also known as the "Arithmetic Moving Average" or "Moving/Rolling Mean/Average" is certainly the most well-known moving average due to its simplicity and numerous applications in other domains. The SMA with period length is commonly calculated as follows:

SMA[t] = (SUM C[t-i])/length, for i = 0 to length-1 = (C[t] + C[t-1] + ... + C[t-length-1])/length

Here all the weights w would be equal to 1/length (which is why we often state that a SMA has uniform weights).

Relationship With The Momentum Oscillator

Changes in a simple moving average with period length are equal to a momentum oscillator of the same period divided by length, that is:

SMA[t] - SMA[t-1] = (C[t] - C[t-length])/length

This can be explained from the calculations of the changes in a Simple Moving Average:

change(SMA[t]) = SMA[t] - SMA[t-1] = (C[t] + C[t-1] + ... + C[t-length-1])/length - (C[t-1] + C[t-2] + ... + C[t-length])/length = (C[t] - C[t-length])/length

The closing prices with the same lag cancel each other out, leaving only C(t) and C(t-length) divided by length in the final calculation.

As such you could tell whether a moving average of period length is rising or declining by simply comparing the current closing price to the closing price length bars ago. If the current closing price is higher; then the moving average is rising, else it is declining.

This relationship allows us to efficiently compute the SMA , allowing us to obtain a computation time independent of the moving average period which is very important for real-time high-frequency applications of the SMA .

Lag Of The SMA

Lag is defined as the effect moving averages have to return past price variations instead of new ones. For most moving averages this amount of lag can be quantified as the weighted sum between the moving average weights w(i) and the time lag associated with them. Higher weights given to more recent values would return a moving average with less lag.

All the weights of a simple moving average are equal to 1/length. The lag of a Simple Moving Average is thus given by:

Lag = SUM(1/length × i), for i = 1 to length-1 = 1/length + 1/length × 2 + ... + 1/length × (length-1) = (length-1)/2

As such, the lag (in bars) of a Simple Moving Average is equal to its period minus 1, divided by 2.

Offsetting an SMA Lag bars in the past allows us to have it centered with the price.

Cascaded SMA's

Using an SMA as input for another SMA would return a smoother output; this process is known as cascading. In the case of the Simple Moving Average , cascading many SMAs of the same period would converge toward a Gaussian function.

The Irwin–Hall Probability Density Function can describe the result of cascading multiple SMAs using an impulse as input.

Curiosities About The Exponential Moving Average

The Exponential Moving Average ; abbreviated as "EMA", also known as an "Exponentially Weighted Moving Average" or "Exponential Average" is a recursive moving average. That is, it uses a previous output for its computation.

This moving average is slightly more reactive than the Simple Moving Average due to its lower degree of filtering.

An EMA of period length is calculated as follows:

EMA[t] = a × C[t] + (1-a) × EMA[t-1]


EMA[t] = EMA[t] + a × (C[t] - EMA[t-1])

with smoothing constant a = 2/(length+1).

Traders Prefer The EMA Over The SMA

The trading community seems to have developed a preference for the EMA over the SMA . This might be explained by the superior reactivity of the EMA over the SMA .

The EMA is also more commonly used in the creation of technical indicators, sometimes for its superior reactivity, its computational efficiency, or sometimes simply by preference.

Several studies attempted to indicate which moving average (between the EMA and SMA ) provided better performances. The conclusion can vary depending on the markets and methodology used. Dzikevičius & Šaranda found superior results of the EMA over the SMA (2), while Predipbhai found better results from an EMA-based MACD over an SMA-based one (3).

The EMA Helps Avoiding Division By Zero

In scenarios where we are required to perform a division with a moving average applied to a denominator, the EMA can help to avoid division by 0 as long as the smoothing factor is lower than 1 ( EMA period superior to 1)

For a< 1, the EMA has an exponentially decaying infinite impulse response. The impulse response converges towards 0 but never reaches it.

This can be useful if we want to obtain the ratio between the average upward variations and average downward variations. In the event where there is a significant number of upward variations, an SMA of the downward variations might eventually be equal to 0; the EMA prevents this.

The EMA Has The Same Lag As An SMA

We previously mentioned that the EMA is more reactive than the SMA , but quantifying the lag of an EMA from the weighted sum between the EMA weights and their associated lag gives the same results as the lag of an SMA .

The weights of an EMA can be obtained from its impulse response, which is described as:

h[n] = a × (1-a)^n, n ∈ [0,inf]

The lag is then calculated as follows:

Lag = SUM i × (a × (1-a)^i), for i = 0 to infinity = (1 - a)/a = (1 - 2/(length+1))/(2/(length+1)) = 2/(length+1)

Curiosities About The Weighted Moving Average

The Weighted Moving Average ; abbreviated as "WMA", also known as a Linearly Weighted Moving Average (LWMA), is the most reactive moving average when compared to the SMA and EMA . The WMA uses linearly decaying weights for its calculations, giving higher weights to more recent prices.

The WMA can be calculated as follows:

Relationship With The SMA

It's interesting to observe how certain moving averages are related to each other. In the case of the WMA and SMA , the change of a WMA of period length can be given by the difference between the price and an SMA offset by 1 bar, divided by (length+1)/2.

This equality is described as follows:

change(WMA[t]) = (1 - SMA[t-1])/((length+1)/2)

This also shows that the changes in a WMA with a period length-1 can indicate if the price is above or below an SMA of period length.

Like with the SMA , this relationship allows the calculation of the WMA efficiently allowing us to obtain a computation time independent of the moving average period.

Relationship With The Linear Regression

It can seem extremely surprising, but it is indeed possible to compute a simple Linear Regression of the price using linear combinations between a WMA and an SMA (under certain conditions).

The first point of a simple Linear Regression with coordinates (X1,Y1) fitted through the most recent length price observations can be obtained as follows:

X1 = t - length + 1 Y1 = 4 × WMA[t] - 3 × SMA[t]

While the last point with coordinates (X2,Y2) is given by:

X2 = t Y2 = 3 × WMA[t] - 2 × SMA[t]

The periods of the WMA and SMA are both equal to length. Drawing a line using the above coordinates would return the simple Linear Regression fitted to the most recent length price observations. The slope of the linear regression is equal to:

m = ((3 × WMA[t] - 2 × SMA[t]) - (4 × SMA[t] - 3 × WMA[t]))/(length-1) = 6*(WMA[t] - SMA[t])/(length-1)


(1) Hoem, J. M. (1984). A contribution to the statistical theory of linear graduation. Insurance: Mathematics and Economics, 3(1), 1-17.

(2) Dzikevičius, A., & Šaranda, S. (2010). EMA Versus SMA usage to forecast stock markets: the case of S&P 500 and OMX Baltic Benchmark. Business: Theory and Practice, 11(3), 248-255.

(3) Predipbhai, N. P. (2013). Comparison between exponential moving average based MACD with simple moving average based MACD of technical analysis . International Journal of Scientific Research, 2(12), 189-197.

Other Stories

Fibonacci Grid

New Feature

The following indicator returns multiple diagonal lines forming a grid. Each line has 45-degree and is set depending on Fibonacci ratios as well as the maximum and minimum price value over a certain lookback period.

Pivot High/Low Analysis & Forecast

New Feature

This indicator returns pivot point high/lows alongside the percentage change between one pivot and the previous one (Δ%) and the distance between the same type of pivots in bars (Δt). The indicator also returns an estimate of the future time position of the pivot points.