How to Calculate Exponential Moving Average in Trading
A commonly used trading indicator is the exponential moving average (EMA), which can be superimposed on a bar chart in the same manner as an SMA. The EMA is also used as the basis for other indicators, such as the MACD (moving average convergence divergence) indicator.
Although the calculation for an EMA looks a bit daunting, in practice it’s simple. In fact, it’s easier to calculate than an SMA, and besides, your charting package will do it for you. Here are the calculations:
EMA [today] = (Price [today] x K) + (EMA [yesterday] x (1 – K))
K = 2 ÷(N + 1)
N = the length of the EMA
Price [today] = the current closing price
EMA [yesterday] = the previous EMA value
EMA [today] = the current EMA value
The start of the calculation is handled in one of two ways. You can either begin by creating a simple average of the first fixed number (N) of periods and use that value to seed the EMA calculation, or you can use the first data point (typically the closing price) as the seed and then calculate the EMA from that point forward. Traders handle it both ways.
It’s the method used in calculating the EMA amounts, which shows a nine-day EMA calculation for Intel throughout May 2008. The EMA value for May 1 is seeded with that day’s closing price of $22.81. The actual EMA calculation begins with the May 2 closing price.
For comparison, here is an SMA calculation to illustrate the difference between an EMA and an SMA.
In this example, the EMA doesn’t show the same nine-day lag at the beginning of the chart as the SMA. Notice that the results of the moving-average calculations also differ. The EMA data is shown as a solid dark line. For comparison, the SMA data is also plotted using a lighter line.
Good news! You don’t have to do this calculation yourself. StockCharts.com can automatically calculate it for you. You’ll find the exponential moving average as one of the overlays in Chart Attributes. You select the type of overlay you want, such as Moving Avg (exp), and then you put in the number of periods. The exponential moving average line is automatically generated on your chart.