GeniusTrader/Indicators/MOM.pm untested

filter: Statementstmt 0.0% 0 / 29 Branchbran 0.0% 0 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 7 Podpod 0.0% 0 / 2 totaltotal 0.0% 0 / 42 CC 3 SCAR 16.7
CC
3
Cov
0%
calculate
12.0
initialize
2.0
BEGIN
2.0
CRAP 5.3
1 package Finance::GeniusTrader::Indicators::MOM;
2  
3 # Copyright 2000-2002 Raphaƫl Hertzog, Fabien Fulhaber
4 # This file is distributed under the terms of the General Public License
5 # version 2 or (at your option) any later version.
6  
7 use strict;
8 use vars qw(@ISA @NAMES @DEFAULT_ARGS);
9  
10 use Finance::GeniusTrader::Indicators;
11 use Finance::GeniusTrader::Prices;
12 use Finance::GeniusTrader::ArgsTree;
13  
14 @ISA = qw(Finance::GeniusTrader::Indicators);
15 @NAMES = ("MOM[#*]");
16 @DEFAULT_ARGS = (12, "{I:Prices CLOSE}");
17  
18 =head2 Finance::GeniusTrader::Indicators::MOM
19  
20 The standard Momentum is the Momentum 12 days : Finance::GeniusTrader::Indicators::MOM->new()
21 If you need a non standard Momentum use for example : Finance::GeniusTrader::Indicators::MOM->new([9]) or Finance::GeniusTrader::Indicators::MOM->new([25])
22  
23 =cut
24  
25 sub initialize {
26 my ($self) = @_;
27 }
28  
29  
30 =head2 Finance::GeniusTrader::Indicators::MOM::calculate($calc, $day)
31  
32 =cut
33 sub calculate {
34 my ($self, $calc, $i) = @_;
35 my $nb = $self->{'args'}->get_arg_values($calc, $i, 1);
36 my $name = $self->get_name;
37 my $mom = 0;
38  
39 $self->remove_volatile_dependencies();
40 $self->add_volatile_arg_dependency(2,$nb+1);
41  
42 return if ($calc->indicators->is_available($name, $i));
43 return if (! $self->check_dependencies($calc, $i));
44  
45 $mom = $self->{'args'}->get_arg_values($calc, $i, 2) -
46 $self->{'args'}->get_arg_values($calc, $i - $nb + 1, 2);
47  
48 $calc->indicators->set($name, $i, $mom);
49 }