Examining The E: A Closer Look at A Classic
Examining The E: A Closer Look at A Classic
by Tim Treloar
he popular exponential
T
moving average (EMA)
depends on data to de-
velop its distinctive char-
acteristics, and when it
comes to data, more is better. But
before you put an EMA to work as a
technical indicator, a deeper under-
standing of its development and be-
havior is advised. At the very least, a
deeper understanding will justify the
practical application of it and at most
dispel some misconceptions associ-
ated with it.
IN THEORY
An E MA is essentially a type of
weighted average. The idea of a
weighted average is simple: each ele-
ment in a collection of numerical data
is multiplied by a number ranging from
zero to 1 (the decimal equivalent of the
percentile range zero to 100), called a
weight, such that the sum of the weights
always totals 1, and the weighted ele-
ments are then added together.
A simple moving average (MA) is
perhaps the simplest example of a
weighted average in that all the ele-
ments receive exactly the same weight.
In an exponential moving average, the
weight of each element decreases pro-
gressively, usually according to its age
and usually by powers of a particular
factor. This is done under the premise that recent data is more value of old data becomes so small that it can be effectively
relevant than older data. The smaller this factor, the faster negligible.
data devalues, heavily favoring the most recent data — in Because the sum of the weights in a collection of data
other words, a short-term EMA. The larger the factor, the always totals 1, weight must be drawn in some manner from
slower data devalues, distributing favor more equitably over among the other weighted elements in order to make weight
a longer range of data — a long-term EMA. At some point, the available for new additional data. Where in the collection of
Copyright © Technical Analysis Inc. www.Traders.com
Stocks & Commodities V. 26:6 (42-46): Examining the EMA by Tim Treloar
INDICATORS
elements this weight is drawn from has a pronounced effect an arbitrarily selected leading weight. Accordingly, 1 – K =
on the short-term evolution of the weight distribution, but in 0.8 represents the remaining weight:
the long run the weight distribution of all EMAs that use the
same parameters will become virtually identical. When rep- EMA 1 = 0.2P1 + 0.8 EMA 0
resented graphically with bars, the characteristic profile of an
EMA weight distribution is a stepped, gradually tapering The sum of the two weights equals 1 as expected. But EMA0
curve, like steps descending into the base of an escalator. represents older data than P1 and, thus, in exponentially
decreasing fashion, its elements should be weighted more
THE TRADITIONAL EMA lightly. The fact that, in this example, the EMA0 weight is
The EMA in its most familiar form is defined recursively as considerably larger than the P1 weight suggests that it con-
follows: sists of more than one piece of data.
To address such situations, EMA0 is typically assigned a
EMA i = Pi K + EMA i – 1 1 – K (1) simple moving average of sufficient length so that the weight
of any one of its elements is less than the leading weight. To
where: determine the number of days in the MA necessary to achieve
K = Leading weight value this, the EMA0 weight is divided according to the inequality:
Pi = Data element value
EMAi = Current EMA
EMAi-1 = Previous EMA 1 – K < K, (2)
N
i = Index by chronological order, i = 1, 2, 3,...
where N is the number of days in the moving average. Solving
Formulas such as equation (1) are known as recursive
for N produces
because the resulting output is plugged back into the formula
along with the next piece of data to determine the next output.
The process can be repeated indefinitely in a recurring N>1–K
pattern. The net result of applying the formula for a pre- K
scribed number of pieces of data can be expressed as a single
equation: Using the values in the example above,
n
+ K Σ Pn – i + 1 1 – K
n i–1
EMA n = EMA 0 1 – K
i=1 N > 1 – K = 0.8 = 4
K 0.2
where n represents the total number of data, excluding the
So the value of N must be at least 5. In order for older data
initializing EMA0 data. The exponents that appear in this form
to have less weight than the leading weight of 0.2, the EMA
of the formula are the reason for the “exponential” in the
must have at least five days of older data. Since moving
EMA’s name. All data devalues according to powers of the
averages are usually defined by a particular number of days,
factor 1 – K. It may be helpful to think of this factor as a
the EMA can be defined in terms of N days by solving
retention factor, as it represents how much value is retained
inequality (2) for K.
from day to day. The weight of any given piece of data in the
ith position in the distribution is given by the expression
K> 1
N+1
i–1
K 1–K
Two very simple expressions for K that satisfy this in-
To better understand how K relates to the perceived length equality are:
of the EMA, let i = 1 to initialize the EMA and let K = 0.2 be
FIGURE 1: TRADITIONAL EMA. When new data is introduced into the calculation, the weight is drawn from the moving average. This reduces the MA height uniformly with
each new piece of data.
ΣP
a smooth distribution, the cumulative weight of the most
recent N pieces of data always accounts for somewhere EMA n = 1 – rn n–i+1 ri – 1
1–r i=1
between 86% and 89% of the total weight. So while there is
a definite correlation between the size of N and the length of The choice of r has an advantage beyond simplicity. With
time required for data to devalue, there is nothing particularly r, any retention rate value in the range between zero and 1 can
“N-day” about an N-day EMA. be selected. When N is used to determine the retention rate,
FIGURE 2: MODIFIED EMA. In the modified EMA there is no initiating MA, so proportional amounts are drawn from every preceding weight when new data appears.
Copyright © Technical Analysis Inc. www.Traders.com
Stocks & Commodities V. 26:6 (42-46): Examining the EMA by Tim Treloar
INDICATORS
many available values will be unselectable because N, repre- However, it is possible to let N represent the number of
senting days, is presumed to be a whole number, and that days where a selected cumulative weight is reached. For
restriction in turn unnecessarily limits the number of avail- instance, if we consider data accounting for 95% of the
able retention rates. forward weight to be relevant, we can design our formula so
In the modified EMA, the weight for any piece of data in the that when we call for an N-day EMA, the retention rate is
ith position is defined as automatically computed so that 95% of the weight always
occurs over the most recent N days. The tail of the distribution
1 – r ri – 1 is still there but accounts for only the remaining 5% of weight.
1 – rn This approach is implemented by defining the retention rate
r in terms of both the desired number of days and the desired
Every weight approaches its own lower limit. The limit cumulative weight percentage:
value of the ith weight is
r=N 1–c
1 – r ri – 1
Technically, the weights never reach their limiting values, CLOSING THOUGHTS
but they do get very close to them. How long does it take for A good EMA should allow us to weight data precisely and
weights to get reasonably close to their limits? At low devalue it smoothly and predictably over selected time frames.
retention rates, newly created weights are much smaller than No EMA will be smooth and predictable if it is not primed with
the weights before them, so large contributions from those enough data for the weight distribution profile to take shape.
preceding weights are not required and the distribution stabi- That consideration aside, which EMA is superior? The
lizes in a relatively short time. At high retention rates, newly traditional EMA appears computationally simpler and boasts
created weights are only marginally smaller than weights fixed-value forward weights, but it generally requires a
before them, requiring larger contributions from preceding moving average to force some semblance of exponential
weights, so the distribution takes longer to stabilize. The decreasing behavior early on. The modified EMA can be
number of data required to do this will vary with the retention initialized with a single piece of data; it is not subject to
factor and how close to the limiting values the weights are unusual initial behavior but appears more computationally
required to be. The formula to determine the minimum demanding and features limit-approaching forward weights.
number of data n is: Another question posed is whether to use a traditional N-day
input, a retention rate r directly, or whether to consider a
ln ε – ln ε + 1 variation of r that takes into account a selected cumulative
n≤ weight over N days.
ln r
In the end, it may come down to user preferences. As is true
where e is the maximum allowable error, as a percentage of of many technical indicators, the power to choose and adjust
the limiting weight. Using the EMA traditional input of N, it parameters is largely what gives the EMA such utility, flex-
generally will take about 2.3 times that amount of data to get ibility, and appeal.
the weights to within 1% of their limiting values.
Tim Treloar has experience as a commodities daytrader and
THE N-DAY DILEMMA position trader and holds degrees in both mathematics and
If an N-day EMA is to have something to do with N days of education. He has taught mathematics for 10 years and also
data, then some meaningful definition must be concocted. does some consulting work.
One idea is to let the number of days N define the boundary
between relevant data and negligible data. But as there is no
universally accepted definition for what constitutes relevant
or negligible data, there can be no universally accepted
boundary. S&C
The statements and opinions expressed in this article are those of the author. Fidelity Investments
cannot guarantee the accuracy or completeness of any statements or data.
620098
1