GeniusTrader/Indicators/Generic/Max.pm untested

filter: Statementstmt 0.0% 0 / 32 Branchbran 0.0% 0 / 6 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 7 Podpod 0.0% 0 / 2 totaltotal 0.0% 0 / 47 CC 4 SCAR 22.2
CC
4
Cov
0%
calculate
20.0
initialize
2.0
BEGIN
2.0
CRAP 9.2
1 package Finance::GeniusTrader::Indicators::Generic::Max;
2  
3 # Copyright 2000-2002 Raphaƫl Hertzog
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 use Finance::GeniusTrader::Prices;
14 use Finance::GeniusTrader::Tools qw(:math);
15  
16 @ISA = qw(Finance::GeniusTrader::Indicators);
17 @NAMES = ("Max[#*]");
18  
19 =head1 NAME
20  
21 Finance::GeniusTrader::Indicators::Generic::Max - Return the max of all parameters
22  
23 =head1 DESCRIPTION
24  
25 This indicator returns the biggest value of all its parameters.
26  
27 =cut
28 sub initialize {
29 my ($self) = @_;
30  
31 }
32  
33 sub calculate {
34 my ($self, $calc, $i) = @_;
35 my $name = $self->get_name;
36
37 return if ($calc->indicators->is_available($name, $i));
38  
39 my $res = $self->{'args'}->get_arg_values($calc, $i, 1);
40 my $expr = "";
41 for (my $n = 2; $n <= $self->{'args'}->get_nb_args(); $n++) {
42 my $val = $self->{'args'}->get_arg_values($calc, $i, $n);
43 if (defined($val)) {
44 $res = max($res, $val);
45 }
46 }
47
48 if (defined($res)) {
49 $calc->indicators->set($name, $i, $res);
50 }
51 }