[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [GT] WWMA is equivalent to EMA, but broken?



Andreas Hartmann wrote:
Hi,

I am convinced that the WWMA Indicator is essentially the same as
the EMA Exponential Moving Average.

One can re-arrange the EMA formula and compare it with the WWMA
formula:

EMA[t] = EMA[t-1] + a * (S[t] - EMA[t-1])
EMA[t] = EMA[t-1] + a * S[t] - a * EMA[t-1]
EMA[t] = a * S[t] + EMA[t-1] - a * EMA[t-1]
EMA[t] = a * S[t] + (1 - a) * EMA[t-1]
EMA[t]  =   a   * S[t] + (1 -  a ) * EMA[t-1]
WWMA[t] = (1/n) * S[t] + (1 - 1/n) * WWMA[t-1]

The last two lines show that WWMA is just using a different
smoothing factor.

The EMA smoothing factor is calculated from a = 2/(n+1), with n
being the value actually passed to the indicator. This n is of
course different from the one passed to WWMA. But it follows from:

a = 2/(n[EMA]+1) = (1/n[WWMA])

that:

n[EMA] = 2*n[WWMA]-1


So, for example, {I::EMA 59} and {I:WWMA 30} are equivalent!

They should, apart from small differences caused by varying
selection of the initial values create the same results. But the
plots of the two look comletely differnt. Is WWMA broken?

Would it be desirable to have the WWMA indicator nevertheless, for
the purpose of making available the differnt weighting of the
smoothing factor?
Or just have WWMA convert the smoothing factor and pass it to EMA?

The problem of the initial value came up in a post a while ago, and
it basically affects every indicator which uses Y[t-1] to calculate
Y[t]. To use the first sample itself would probablay a sensible
default, and uniform configurability for all affected indicators
desirable.
Another issue is whether the initial value should be taken from the
beginning of the desired range or from the beginning of all available
data.

I have tried to fix WWMA but I am battleing with messages like:
Use of uninitialized value in numeric gt (>) at ../GT/Graphics/Tools.pm line 175


By the way, there is another WWMA formula at
http://www.fmlabs.com/reference/WellesMA.htm
which also translates to EMA.


Andreas


the Wilders.pm code was never committed -- my notes indicate:
 i) the corrected ADX.pm (03/02/08) (also not committed) will need
    change if Wilders.pm name is changed
ii) similarly, other modules using WWMA.pm might benefit from
    change to Wilders.pm


archive messages since first of 2008 that i've found
discussing welles wilders smoothing include:
 wilders.pm code (sub: wilders smoothing dated 03/02/08)
 some commentary on wilders.pm code and wwma code in the ADX thread
  (sub: ADX dated 03/02/08)
 more discussion in wilders versus wwma thread (sub: wilders versus wwma and adx
  dated 03/17/08)

for what it is worth, if the current wwma.pm is implemented incorrectly
then the corrected version should replace it. on the other hand, if there are
significant ambiguities in the interpretation of the welles wilder smoothing algorithm
that result in (significantly) different implementations across the spectrum of
technical analysis codes maybe gt should support more than one. but the module
name should be more descriptive than Wilders.pm.

aloha

ras