Moving Average

What is a Moving Average?

A moving average is used in technical analysis to summarise large amounts of data by picking one number to represent that data.

The reason for calculating the moving average of a stock is to help smooth out the price data by creating a constantly updated average price.

πŸ’‘
What you need to know:
  • The moving average is a technical analysis tool to help you understand asset price data.
  • By calculating a moving average, the impact of short-term price fluctuations are mitigated.
  • There are two types of moving averages: the Simple Moving Average (SMA) and the Exponential Moving Average (EMA).

The Basics

In maths, an average is a way of summarising data by picking one number to represent that data.

If we had the numbers 4, 5, 3, 4, 7, 6, 4, 2, 3, 4 and we wanted to pick one number to represent this data, we would calculate the average of the numbers. In this case, there are three types of average:

  • Mean = sum of all number divided by the number of numbers = (4 + 5 + 3 + 4 + 7 + 6 + 4 + 2 + 3 + 4) / 10 = 42 / 10 = 4.2
  • Median = the middle of the sorted numbers: 2, 3, 3, 4, 4, 4, 4, 5, 6, 7 = 4
  • Mode = the most common number = 4

The precise method of finding the average isn't too crucial, but the concept of looking at that data and seeing a number around 4 being the most representative is the important part.

How is it calculated?

A moving average is the same concept but applied to data that changes over time. Let's imagine that the numbers above were actually asset prices (in $) over a 10-day period.

If we used the mean, we'd say that the 10-day average price was $4.20. If the price on day 11 was $3, the 10-day average price would now involve chopping off the first day's price and using the prices from Day 2 to Day 11 to calculate the next average price:

  • 10-day average price (Day 10) = $4.20
  • 10-day average price (Day 11) = (5 + 3 + 4 + 7 + 6 + 4 + 2 + 3 + 4 + 3) / 10 = 41 / 10 = $4.10
  • 10-day average price (Day 12) = (sum of prices between Day 3 and Day 12) / 10
  • 10-day average price (Day 13) = (sum of prices between Day 4 and Day 13) / 10
  • And so on...

If we continue to do this, we end up calculating a whole series of averages over time - a moving average. Just like each average gives a picture of the data set it came from, a moving average captures the trend of data over time.

As a result, a moving average gives a summary of the original data but is smoothed out.

By calculating a moving average, the impact of short-term price fluctuations are mitigated.

To calculate the moving average, we first need to decide over how many days we wish to run the calculation over. For example, a 50-day moving average uses a shifting 50-day data window.

Example

The chart below shows the Tesla closing price, along with 50-day and 200-day moving averages since the start of 2020. It’s clear that both the moving average lines show the price trend over time, with the 50-day moving average being more impacted by price fluctuations than the 200-day moving average:

image

Simple Moving Average (SMA)

The most basic form of moving average is the Simple Moving Average (SMA).

How is it calculated?

SMA=βˆ‘Pdn\small{SMA = \frac {\sum{P_d}} n}

where:

  • Pd=Priceondayd.\scriptsize{P_d = Price\;on\;day\;d.}
  • n=Numberofdays.\scriptsize{n = Number\;of\;days.}

A weakness of the simple moving average is that it treats each day equally, i.e. in the mean calculation, the newest price has the same weight as the oldest price. In order to give more weight to more recent prices, some traders prefer to use the Exponential Moving Average.

Exponential Moving Average (EMA)

The Exponential Moving Average (EMA) is a type of moving average that gives more weight to recent data. As such, it is more responsive to new information than the Simple Moving Average (SMA).

How is it calculated?

EMAd=Pd(s1+n)+EMAdβˆ’1[1βˆ’(s1+n)]\small{EMA_d = {P_d \lparen{\frac {s} {1+n}}}\rparen+EMA_{d-1} \lbrack{1 - \lparen{\frac {s} {1+n}}}\rparen\rbrack}

where:

  • EMAd=EMAondayd.\scriptsize{EMA_d = EMA\;on\;day\;d.}
  • Pd=Priceondayd.\scriptsize{P_d = Price\;on\;day\;d.}
  • EMAdβˆ’1=EMAondaydβˆ’1.\scriptsize{EMA_{d-1} = EMA\;on\;day\;d-1.}
  • s=Smoothingfactor.\scriptsize{s = Smoothing\;factor.}
  • n=Numberofdays.\scriptsize{n = Number\;of\;days.}