Quote from qtip:
thanks so much! Is the smoothing constant always 2, or do I choose the constant myself. If so, is this the same as the period?
The smoothing constant is never 2; it is always a value between zero and one.
Here's where
2/(n+1) comes from.
A simple moving average (sma) is based on the basic statistical idea of averages. If you have seven people in a group, you can find their average weight by adding the seven weights and dividing by 7. You can apply the same principle to average any group of numbers. A
moving average is just an average of a single quantity that changes over time, e.g., closing prices. The basic moving average is called a
simple moving average because all the values are treated equally. This is in contrast to a weighted moving average (wma), where the more recent values are given more
weight than older values.
The advantage of the sma is that you reduce the variance (read: noise) of the data. In other words, you smooth things out. The disadvantage is that, because you're mixing old data together with new data, your average is more representative of the past than the present. This is called
lag. The wma has less lag than the sma for a given value of n (= the lookback period, or sample size), but this is at the cost of more variance. There is always a trade-off between smoothing and lag with moving averages.
Now look at the exponential moving average. The proper name for this beastie is
simple exponential smoothing (ses), and it really represents an infinite geometric series. You can go through the math and show that the ses also performs smoothing of data, at the cost of introducing lag into the output. The smoothing constant is generally represented by the Greek letter alpha, but I'll just use "A" here.
Believe it or not, all this build-up has a point.
The reason
ses is commonly referred to as
ema (exponential
moving average) is because you can establish an equivalency between ses and
sma.
I will state the following without proof:
The lag produced by ses is (1 - A)/A.
The lag produced by sma is (n - 1)/2.
If we set the two lags equal to each other, we get
A = 2/(n + 1)
So we can talk about, say, a '10-day ema', even though strictly speaking, A represents a fraction between 0 and 1, not a real sample size of data like n.
hth