where SMA is the simple, garden variety Moving Average and P_{N+1} is the current price.
Then I wrote down the magic formula for the obtained by replacing MA by EMA, in [0]. >What's that α ?
>Hence, the big question: - For any positive α < 1, we'll define the N-day EMA as:
(a) EMA = (α^{N-1}P_{1}+ α^{N-2}P_{2}+ ... + P_{N}) / K
That's the weighted average of N prices, with weights 1, α, α^{2}, ... α^{N-1}, P_{N}being the most recent price Note that the price N days (weeks? months?) ago is given a smaller weight of α^{N-1}, if α < 1 It's the powers of α that makes it an__exponential__average. - We choose K so that, if all prices are equal to P, then the EMA equals P as well. That means:
(b) P = (α^{N-1}P + α^{N-2}P + ... + P) / K hence (c) K = 1 + α + α^{2}+ ... + α^{N-1}= (1 - α^{N}) / (1 - α) ... using the formula for the sum of a geometric series - If the P's are (say) daily prices, then the
__next__day we'd calculate: (d) EMA' = (α^{N-1}P_{2}+ α^{N-2}P_{3}+ ... + P_{N+1}) / K
... where now P_{N+1}is the most recent price - Now, from from (a) and (d), we calculate:
(e) EMA' - α EMA = (P_{N+1}- α^{N}P_{1}) / K - We now have:
(e) EMA' = α EMA + (P_{N+1}- α^{N}P_{1}) / K - Finally, we substitute that K-value we got above, in (c):
(f) EMA' = α EMA + (1 - α) (P_{N+1}- α^{N}P_{1}) / (1 - α^{N})
If all prices were equal to P (hence EMA = EMA' = P), then (f) would read P = P ... which is comforting.
If α is small enough and N is large enough, we might ignore α ^{N}.
That's like going back to the big bang, rather than just N days. Ignoring α ^{N}, that'd give the "standard" formula [1], namely:
[3] EMA' = α EMA + (1 - α) P
_{N+1}Remember: EMA is today's calculated value, EMA is yesterday's ... and P _{N+1} is today's price.
Note, too, that if all prices were equal to P, then [3] would read P = P. >And that answers the question: Figure 1 >Yeah, so I see stock prices in green, but where's the two EMAs?
>The colour is purple, right?
> >So have you answered the question:
>Uh ... I sort of like f(N) = tanh(N-1)
>Yeah, yeah, but what's the BEST?
>I would have thought that |