NAME
Math::Business::MACD - Perl extension for calculating MACDs
SYNOPSIS
use Math::Business::MACD;
my $macd = new Math::Business::MACD;
my ($slow, $fast, $trigger) = (26, 12, 9);
set_days $macd $slow, $fast, $trigger;
my @closing_values = qw(
3 4 4 5 6 5 6 5 5 5 5
6 6 6 6 7 7 7 8 8 8 8
);
foreach(@closing_values) {
$macd->insert( $_ );
print " MACD: ", $macd->query, "\n",
"Trigger EMA: ", $macd->query_trig_ema, "\n",
" Fast EMA: ", $macd->query_fast_ema, "\n",
" Slow EMA: ", $macd->query_slow_ema, "\n";
}
# to avoid recalculating huge lists when
# you add a few new values on the end
$ema->start_with(
$last_slow_ema,
$last_fast_ema,
$last_trig_ema,
);
# then continue with a foreach over the newly
# inserted values
# unfortunately this means you'd have had to
# store the last slow, fast, and trigger ema's.
# somewhere
EMA/SMA Note
As of SMA 0.99, EMA 1.06, MACD 1.10, the MACD will now return
'undef' where there is not yet enough data to calculate the EMAs.
Further, the trigger and histogram values will not be available until
the trigger EMA has enough data.
This is going to be a compat buster for some of my graphs, but it has
to be done for correctness. :(
AUTHOR
Jettero Heller <jettero@cpan.org>
http://www.voltar.org
Thanks
David Perry <David.Perry@ca.com>
Special Thanks
http://www.stockcharts.com/education/What/IndicatorAnalysis/indic_MACD1.html
SEE ALSO
perl(1), Math::Business::EMA(3).
Go Read this Page:
http://www.stockcharts.com/education/What/IndicatorAnalysis/indic_MACD1.html