Math::SMA - SMA in object form
use Math::SMA;
my $sma = Math::SMA->new(size => $n);
$sma->sma($value);
Implements a simple moving average of N periods with an amortized runtime complexity of < O(n²).
http://en.wikipedia.org/wiki/Moving_average
Create a new SMA object of $n
periods.
my $sma = Math::SMA->new(size => $n);
Add a value to series and return the current simple moving average
$sma->sma($current);
$current
is the current live value
Returns last_avg
if called with no arguments.
The precision level for decimal places. Defaults to 2.
The current value of the SMA series.
The current values of the SMA period. If you want to continue a series from a previous time, then pass an arrayref in during object construction:
$sma = Math::SMA->new(size => 5, values => [3,2,7,4,9] );
Samuel Smith <esaym@cpan.org>
See http://rt.cpan.org to report and view bugs.
The source code repository for Math::SMA can be found at https://github.com/smith153/Math-SMA.
Copyright 2015 by Samuel Smith <esaym@cpan.org>.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.