The simple moving average and the exponential moving average can help traders find price trends.


“The trend is your friend,” say some traders.

“. . . until it ends,” finish others.

Whatever your philosophy, identifying trends can be helpful for determining price direction. A common technical indicator many traders use for identifying trends is a moving average.


What Is a Moving Average?

A moving average (MA) is a technical indicator that analysts may use to determine the direction of a financial security’s trend. Analysts calculate a MA by adding all the data points of a security over a specific time period; then, they divide the sum by the number of data points to arrive at an average. The moving average plots the data point on a line and smooths out price fluctuations, which can help an investor understand the general direction of the trend.

The MA is called “moving” because it is constantly recalculated based on the most recent price data. Technical analysts may refer to the MA as a lagging indicator, which is an indicator that shows patterns that have already happened (rather than anticipating possible future events). Since investors can customize the time frame for the moving average, the amount of “lag” can differ; for instance, a moving average that contains prices from the past 200 days might have more lag than a 20-day moving average. 

The MA doesn't work well in non-trending or sideways markets as they generate whipsawed signals. Another drawback is with companies in highly volatile industries or those impacted by current events. It also can be risky with utility companies sensitive to cyclical demand and supply.

Two types of moving averages are the simple moving average (SMA) and the exponential moving average (EMA). A SMA calculates the average of price data, while an EMA gives more weight to recent data. The newest price data would impact an EMA more, whereas the SMA considers all data equally.

moving average lines on chart

Source: Alex Kofman via Wikimedia Commons

How Can I Calculate the Simple Moving Average?

Compared to the EMA, calculating the simple moving average is — well, simpler. The SMA is the mean of the price data within a timeframe. 

  1. Find the sum of the price for each day of the timeframe you want to measure. Investors usually use the closing price for the average.

Example: If you want to calculate a 20-day moving average, add the closing prices over a 20-day period.

  1. Next, divide that number by the number of days in your determined timeframe. 

Example: In a 20-day moving average, you would divide the sum from step 1 by 20.

simple moving average formula


To create a moving average, each day you can drop the oldest day from the data and add the most recent.


How Can I Calculate the Exponential Moving Average?

In an attempt to account for the lag time of the SMA, the exponential moving average gives more weight to recent price data.

  1. First, you’ll need to determine the previous day’s EMA. To start, you can find the SMA.

Example: For a 20-day EMA, determine the SMA from the 20th day. On Day 21, use the SMA from Day 20 as the EMA for the previous day.

  1. Next, calculate the weighting factor by using this formula: [2 / (number of observations + 1)]. 

Example: In a 20-day moving average, the weighting factor is [2 / (20+1)] = 0.0952

  1. Use these numbers to calculate the EMA formula:

EMA = weighting factor x (current price - previous EMA) + previous EMA

exponential moving average formula


Which Moving Average Should I Use?

Investors who use long-term strategies may use the simple moving average to see overall trends. On the other hand, day traders and other short-term investors may prefer the exponential moving average because the EMA can signal recent direction changes more quickly. 

An EMA might be helpful during an abrupt price change, since the EMA can signal it faster than the SMA. This can alert a trader to sell before the price plummets farther, for instance. However, following the quick price changes with an EMA may make a trader prone to recency bias. If the abrupt price change is a brief hiccup instead of an ongoing trend, that trader may have lost the opportunity to profit from that trade.

The SMA can help traders identify reversals and trends, determine momentum, and find potential support and resistance areas. Nonetheless, historical performance might inform a trader’s decisions, but past performance can’t necessarily predict future results, since there are many factors that can affect market behavior. And by the time an analyst identifies a trend, that could mean that most of that trend has already taken place. 

Ultimately, selecting the right moving average(s) depends on the individual trader’s strategy. Combining a moving average with other indicators can help inform traders’ decisions.


What’s Next: Try the Score Priority Trading Platform Demo