0
$\begingroup$

https://school.stockcharts.com/doku.php?id=technical_indicators:moving_averages

It says "First, calculate the simple moving average for the initial EMA value. An exponential moving average (EMA) has to start somewhere, so a simple moving average is used as the previous period's EMA in the first calculation."

Why not just do something like this, for 1<= i <len?

EMA[i] = (close[i]-EMA[i-1])*lambda + EMA[i-1], where lambda=2/(i+1).

The advantage is that there are still values for 1<= i <len. But using the definition in the cited page, there will be no definition for those periods.

Has anybody used my definition? If so, is there a reference for this version of EMA definition?

$\endgroup$

1 Answer 1

2
$\begingroup$

In brevety: Yes, you can use your ansatz, but it simply should not matter too much. Note: The standard (Wikipedia) definition sets $EMA_0=X_0$.

Why is the starting value not really relevant: Given observations $X_t$, $t=0,1,2,\ldots$, the EMA $S_t$ can be written as

$$ \begin{align} S_t&=\lambda X_t+(1-\lambda)S_{t-1}\\ &=\lambda\sum_{i=0}^{\infty}(1-\lambda)^iX_{t-i} \end{align} $$ Where the $\infty$ is used as shorthand for "use all data points from the past". In most practical cases, the choice of the initial value becomes irrelevant after a couple of lags:

lambda    n     weight of first element
0.01      25    0.78 %
0.01     100    0.37 %
0.1      25     0.72 %
0.1      100    0.00 %
0.9      25     0.00 %
0.9      100    0.00 %
0.99     25     0.00 %
0.99     100    0.00 %
$\endgroup$
3
  • $\begingroup$ You did not answer my question. I care about the initial few periods. $\endgroup$ Apr 14, 2022 at 20:55
  • $\begingroup$ I tried to convey that the question "how to handle the first couple of points" is irrelevant for nearly all practical purposes. Hence, you may use whatever you deem fit (as long as it's not too wild a starting point). BTW: Your post contains three seperate questions - I understood you wanted to know whether your ansatz is sensible. My answer is: yes, you may do that, given a sufficiently long data series (say 25 or more data points, and lambda not too wild). HTH? $\endgroup$ Apr 14, 2022 at 21:22
  • $\begingroup$ Kermitt frog answered ( correctly I might add ) by saying that the standard approach is to use the first value as the initial EWMA value. As long as you have some decent number of observations ( say 50 ), the first couple of periods are not going to end up playing a role anyway. Regardless of the value of $\lambda$, the weight given to them in the EWMA gets less and less and less the further one goes out. $\endgroup$
    – mark leeds
    Apr 14, 2022 at 21:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.