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

[GT] EMA incorrect when using --nb-item



Hello All,

I don't know if this is intentional, but when calculating EMA (and my
guess is that the same is true for all other indicators that give more
wight to the more recent dates) the values produced are incorrect if
--nb-item is used, or if --start and --end are used.

Example:
./display_indicator.pl --full --nb-item=10 I:EMA YHOO 60
...
...
EMA[60, {I:Prices CLOSE}][2010/07/19] = 15.7129
15.712 is wrong value for YHOO's EMA for that day.

After analyzing EMA.pm, it seems the problem is that it does its
calculations based on the last 10 (or --nb-item) prices.
A simple fix would be to add $first = 1 inside the
calculate_interval() subroutine, thus giving it the full range of
prices to work on.

Nick