An SMA is calculated by adding the security’s price for the desired lookback period (say, five days) and dividing by the same number (in this case, five). Each day, we add the new day and drop the oldest.

For example, assume these seven daily closing prices: 101, 102, 103, 104, 105, 106, 107. On the fifth day of this sequence, the average would be (101 + 102 + 103 + 104 + 105) / 5 = 103. On the second day of this sequence, the average would be (102 + 103 + 104 + 105 + 106) / 5 = 104. On the third day of this sequence, the average would be (103 + 104 + 105 + 106 + 107) / 5 = 105. Such an average is probably too sensitive to price changes because small changes in price quickly are reflected in changes in the average.

This is where EMAs are helpful. Because EMAs emphasize more recent prices in their calculation, we can achieve a smoother average line with nearly the same level of reactivity.

EMAs are based on the most recent value of the average, the most recent raw price and a weighting multiplier. The weighting multiplier can be changed to mimic a comparable length SMA. For the initial EMA calculation, an SMA of the target length is substituted for the previous-period EMA.

First, we calculate the value of the multiplier.

Multiplier = (2 / (Time periods + 1) ) = (2 / (5 + 1) ) = 0.33

Then, we insert the multiplier value into the following EMA formula:

EMA = [Close – EMA(previous day)] x multiplier + EMA(previous day)

“Average comparison” (above) shows the values of a five-day SMA and EMA for Apple. The exponential moving average starts with the simple moving average value of 449.61 in the first calculation. After the first calculation, the EMA formula takes over. The chart of the EMA is shown in “Apple smoothie” (below).

Because the EMA gives more weight to recent price action, whipsaws are less frequent. As seen in the chart, Apple closing prices stay above the stock’s five-period EMA throughout most of the uptrend that started in January 2012.