An N-day exponential moving average (EMA) is a weighted average of today’s close and the preceding EMA value. The weight for today’s close is a smoothing factor alpha, where alpha=2/(N+1).
EMA[today] = alpha * close + (1-alpha) * EMA[yesterday]
The formula can also be written as follows, showing how the average moves towards today’s close by an alpha fraction of the distance from the old EMA to the new close.
EMA[today] = EMA[yesterday] + alpha * (close + EMA[yesterday])
Expanding out gives a power series with successively decreasing weight for each day’s price. Writing f=1-alpha and with p1 today’s closing price, p2 yesterday’s, etc, then
p1 + p2*f + p3*(f^2) + p4*(f^3) + ... EMA = ------------------------------------- 1 + f + f^2 + f^3 + ...
This is an infinite sum, but f is less than 1 so each successive weight f^k is smaller and smaller, soon becoming negligible. The most recent N days make up about 86.5% of the total. The following graph shows how the weights decrease for N=10.
Because recent prices have a higher weighting that past prices, the EMA responds more quickly and tracks recent prices more closely than a simple moving average (see Simple Moving Average).
When working with N-day periods, it should be noted that J. Welles Wilder uses a different reckoning of the decrease factor for EMAs. For example for a 14-day EMA he writes
1 13 EMA[today] = -- * close + -- * EMA[yesterday] 14 14
This is the same as the formula above, just a different f factor. When Wilder gives “W” days, the equivalent “N” above is 2*W-1, so say 14 becomes 27. This is also sometimes called a “modified moving average”.
In the indicators designed by Wilder, Chart uses his reckoning, so that for instance a 14-day RSI is entered at 14. This applies to ATR, DMI (and ADX) and RSI (see Average True Range, Directional Movement Index, and Relative Strength Index).
Copyright 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2014, 2015, 2016, 2017 Kevin Ryde
Chart is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3, or (at your option) any later version.