GeniusTrader/Indicators/Generic/Abs.pm untested

filter: Statementstmt 0.0% 0 / 19 Branchbran 0.0% 0 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 5 Podpod 0.0% 0 / 2 totaltotal 0.0% 0 / 30 CC 3 SCAR 18.4
CC
3
Cov
0%
calculate
12.0
initialize
2.0
BEGIN
2.0
CRAP 6.3
1 package Finance::GeniusTrader::Indicators::Generic::Abs;
2  
3 # Copyright 2008 João Antunes Costa
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 # Standards-Version: 1.0
8  
9 use strict;
10 use vars qw(@ISA @NAMES);
11  
12 use Finance::GeniusTrader::Indicators;
13 @ISA = qw(Finance::GeniusTrader::Indicators);
14  
15 @NAMES = ("Abs[#1]");
16  
17 =head1 NAME
18  
19 Finance::GeniusTrader::Indicators::Generic::Abs - Return the absolute value of its 1st parameter
20  
21 =head1 DESCRIPTION
22  
23  
24  
25 =cut
26 sub initialize {
27 my ($self) = @_;
28 }
29  
30 sub calculate {
31 my ($self, $calc, $i) = @_;
32 my $name = $self->get_name;
33  
34 return if ($calc->indicators->is_available($name, $i));
35  
36 my $val = $self->{'args'}->get_arg_values($calc, $i, 1);
37 return unless (defined($val));
38 my $res = abs($val);
39 $calc->indicators->set($name, $i, $res);
40 }