What is a moving average?
A moving average (MA) is an indicator used by investors, primarily those that practice technical analysis, to get a clearer picture of a trend in price movement. The moving average calculates price movement over a given period of time. A moving average provides a way for traders to filter out random price fluctuations that are not consistent with a current trend.
By definition, the moving average is a trailing indicator. This simply means that it relies on data that has already happened. So while it is useful as a predictive indicator, it is not the only tool that traders will rely on for information.
Moving averages can be set for any length of time an investor wants to measure. The longer the time frame, the greater the amount of trailing data, meaning the less sensitive it is to current price movements. So a 200-day moving average will have a greater lag than a 20-day moving average. Which moving average an investor uses will depend on their trading objective. Investors with shorter term trading objectives will generally want to use short-term moving averages. Conversely, investors with longer-term trading objectives will typically look at long-term moving averages.
Two of the most widely followed moving averages are the 50-day and 200-day. When prices break above or below these averages it is considered a significant trading signal. Other common moving average periods are 10, 20, and 100-day averages.
Moving averages typically are based on the closing price of a security. However, because the moving average is just a calculation, the price that is used is flexible. There are moving averages that are based on the opening price or another regular data point. For the purposes of this article, assume that we are looking at the closing prices.
How is a moving average calculated?
There are three basic types of moving averages: a simple moving average (SMA), a linear weighted moving average (LWMA or just WMA) and an exponential moving average (EMA). The difference between the three is the formula used to calculate them. To understand why each one exists, it’s important to look at them individually.
Simple Moving Average (SMA)– this is really just basic math. SMA is a calculation of the arithmetic mean that you learned in school. You take a series of recent closing prices, add them together, then divide that total by the number of closing prices you’re measuring (i.e. the time period).
For example in the 10 trading days between August 14-August 27, 2018, the closing price for Apple (NASDAQ: AAPL) stock was as follows:
Date
Closing Price
8/27/2018
219.50
8/24/2018
217.94
8/23/2018
216.16
8/22/2018
215.49
8/21/2018
215.04
8/20/2018
215.46
8/17/2018
217.58
8/16/2018
213.32
8/15/2018
210.24
8/14/2018
209.75
To calculate the SMA, you would add up the closing prices for all 10 days:
(219.50 + 217.94 + 216.16 + 215.49 + 215.04 + 215.46 + 217.58 + 213.32 + 210.24 + 209.75) = 2,150.48
Then you would divide that number by 10 (the number of days in the set): 2,150.48/10 = 215.04
So Apple’s SMA for that 10-day period was $215.04.
To plot the 10-day moving average on a stock chart, you would place a dot each day indicating the 10-day moving average calculated for that day and then draw a line to connect the dots.
This brings up a key point about moving averages. The reason why they're called moving averages is that the data is always "moving" to reflect the latest prices. So in our example, once the closing price for Apple was set on 8/27/2018, that price went into the 10-day SMA and the price for 8/13/2018 was removed. So you’ll always be dealing with only a 10-day sample.
Before computers and their processing power became accessible to a wide audience, the Simple Moving Average was the primary moving average tool used because it was quick and easy to calculate. However, with the advent of software that can perform sophisticated calculations at the blink of an eye, coupled with the movement towards online trading, traders began to desire more precision than the SMA is intended to deliver. As traders began to look at price movement, they theorized that current closing prices should have more weight in the moving average than prices further back in time. This led to the creation of weighted moving averages. The most common types are the linear weighted moving average and the exponential moving average.
Linear Weighted Moving Average (LWMA or WMA)- This type of moving average assigns a multiplier (or weight) to data points according to how current they are, and the difference between one data points “weight” and another is 1 (i.e. linear).
If this sounds complicated, it’s really not. Let’s use our Apple example, but let’s just use the five most recent trading days.
Date
Closing Price
Multiplier (Weight)
Weighted Price
8/27/2018
219.50
5
1097.50
8/24/2018
217.94
4
871.76
8/23/2018
216.16
3
648.48
8/22/2018
215.49
2
430.98
8/21/2018
215.04
1
215.04
To calculate the 5-day WMA, you would multiply the closing price by its multiplier for all 5 days. I did this in the "Weighted Price" column. After that, you add all five numbers and get 3,263.76.
Here’s where the magic happens. If you add up each of the multipliers, it totals 15. So you would divide the weighted price by 15 to get the WMA.
So Apple’s WMA for that 5-day period was: 3,623.76/15 = $217.58
The SMA, by comparison, is $216.91.
As you can see, the weighted average is more closely reflecting the higher closing prices since 8/24.
Exponential Moving Average (EMA)– this is another form of weighted average and the most commonly used. The EMA also uses a multiplier. However, instead of using a linear weighted method (which is arbitrary), the EMA is calculated using the closing price, plus the EMA from the day before. This is done using a three-step calculation:
Calculate the SMA
Calculate the multiplier (or weight)
Calculate the EMA
So let’s use our example one more time:
Date
Closing Price
8/27/2018
219.50
8/24/2018
217.94
8/23/2018
216.16
8/22/2018
215.49
8/21/2018
215.04
Step One: Our SMA, as we calculated above, is 216.91. Easy, right?
Step Two: To calculate the multiplier, you divide 2 by the number of time periods plus 1. So in our example, the multiplier would be 2/(5+1) = 0.33
Step Three: This step relies on you knowing the previous day’s EMA. You take the closing price, subtract the previous day’s EMA, then multiply the difference by the multiplier and add the prior day’s EMA:
EMA = (Today’s closing price - Yesterday’s EMA) * Multiplier + Yesterday’s EMA
Of course, manually calculating the EMA would require you to go back to the beginning of the dataset and calculate each day’s EMA, since the EMA calculation requires data from the day before. Hypothetically, let’s assume that the linear weighted moving average (217.58) was the previous day’s EMA.
You would take the closing price of $219.50 and subtract 217.58 = 1.92.
Multiply 1.92 by our multiplier (0.33) = 0.63
Then add 0.63 to the previous day’s EMA (217.58) = 218.21
Although this is a hypothetical example, you can see how there is almost a $1.30 difference between the SMA and the EMA. What is more significant is how the EMA will react to price changes. When viewed on a stock chart, the EMA will respond to a trend faster than the SMA, which is why short-term traders usually prefer the EMA.
A final note about calculating moving averages: you don’t have to do it. Any charting software package will do those calculations for you. The formulas were provided here to illustrate the difference and explain why traders may prefer one over another.
How to use a moving average for trading
Since a moving average is tracking the price of a stock it is logical to say that when the moving average is moving up it signals a positive price movement and when it’s moving down it signals a negative price movement. A moving average can also indicate where a stock has support or resistance. When a stock cannot seem to cross above a moving average, the stock is said to be at a resistance point. The moving average will look like a ceiling that prices cannot rise above. On the opposite end, when a stock price is failing to cross below the moving average it is seen as providing support for the stock price. In this case, the moving average will look like a floor that the stock price will not fall beneath.
One of the most popular strategies that traders employ is the crossover strategy. When the price of a stock crosses above its moving average this is usually a good signal that the price is ready to increase. Likewise, when the stock price dips below its moving average it's usually an indicator that the stock is about to drop. To help add more certainty, traders will often use two moving averages of different lengths, for example, a 20-day and a 50-day. Because the 50-day has more lag, seeing a price move past both averages is more significant. When a stock rises above both averages it is referred to as “The Golden Cross”. This is seen as a good indicator that the price of a stock is about to rise significantly. Conversely, when a stock dips below both moving averages it is seen as an indicator that the price is about to drop. This is known as “The Death Cross”.
What are the disadvantages to the moving average?
The primary disadvantage to the moving average is the same disadvantage that is inherent in all stock price movement. Stocks don’t always behave logically. They certainly don’t move in the same direction all the time. When a stock is behaving in a volatile fashion, the moving average will not adjust in time to be the best predictor of short-term movement.
The bottom line on moving averages
As we said earlier, if it can be measured, our society tends to measure it. The only question, then, is how much weight we give these measurements in our decision making. There are many variations on the moving average. Some traders will create custom moving averages that may work very well for them. As with any statistical analysis, however, care must be taken to ensure data integrity. The key to effectively using moving averages is to suspend your own predictions and go where the data leads.
Often times a moving average can be tweaked to the extent that it shows only what the trader wants to see and not what is actually there. We see this phenomenon commonly in sports where a heavy reliance on “deep data” can cause organizations to overlook a player’s obvious shortcomings, or to discount another player’s intangibles. In the same way, slicing the onion of moving averages too fine can create a self-fulfilling prophecy, whereby the inputs are skewed to deliver the desired output.
To recap, a moving average is a lagging indicator that is intended to give investors a view of where a security is trending without the outlying moves in price that can cause knee-jerk reactions. There are three basic types of moving average: the simple moving average, the weighted moving average, and the exponentially weighted moving average. Each serves the same purpose but has a different correlation to price movement based on how it is calculated.