[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GT] Re: EMA incorrect when using --nb-item
Nick Fantes Huege wrote:
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
aloha nick
the options -full and -nb-items are thought to be mutually exclusive
(but are not processed that way by the code unfortunately).
generally speaking --full, --start=<date>, --end=<date>, --nb-item=<nr>
are used to set the time period to run the analysis on. by default
(without any of these options) only the most recent 200 bars are used,
which implicitly sets --end.
the analysis range can be controlled by --full (run analysis on every bar
in database), or by using one or two of --start, --end or --nb-item.
in this situation, the total number of bars used would be computed from
the fixed reference, either the explicitly set --start or --end
(either the implicit value or the explicitly set one).
i'm not sure why you would want to use --nb-item=10 and also use a 60
bar time period ema?
as far as your analysis of the GT::Indicators::EMA::calculate_interval
method; it is believed that when passed a valid interval range the computed
ema values are correct. this is implicitly suggesting when used as you
describe, display_indicator.pl is not passing a valid interval range.
ras