NAME
Math::Business::EMA - Technical Analysis: Exponential Moving Average
SYNOPSIS
use Math::Business::EMA;
my $avg = new Math::Business::EMA;
$avg->set_days(7);
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
);
# choose one:
$avg->insert( @closing_values );
$avg->insert( $_ ) for @closing_values;
if( defined(my $q = $avg->query) ) {
print "value: $q.\n";
} else {
print "value: n/a.\n";
}
To avoid recalculating huge lists when you add a few new values on the end:
$avg->start_with( $the_last_calculated_value );
For short, you can skip the set_days() by suppling the setting to new():
my $longer_ema = new Math::Business::EMA(10);
AUTHOR
Paul Miller <jettero@cpan.org>
I am using this software in my own projects... If you find bugs, please please please let me know.
I normally hang out on #perl on freenode, so you can try to get immediate gratification there if you like. irc://irc.freenode.net/perl
COPYRIGHT
Copyright (c) 2008 Paul Miller -- LGPL [Software::License::LGPL_2_1]
perl -MSoftware::License::LGPL_2_1 \
-e '$l = Software::License::LGPL_2_1->new({
holder=>"Paul Miller"});
print $l->fulltext' | less
SEE ALSO
perl(1), Math::Business::EMA(3).