GeniusTrader/Indicators/Range.pm untested

filter: Statementstmt 0.0% 0 / 24 Branchbran 0.0% 0 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 6 Podpod 0.0% 0 / 2 totaltotal 0.0% 0 / 36 CC 3 SCAR 17.5
CC
3
Cov
0%
calculate
12.0
initialize
2.0
BEGIN
2.0
CRAP 5.8
1 package Finance::GeniusTrader::Indicators::Range;
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 # Standards-Version: 1.0
8  
9 use strict;
10 use vars qw(@ISA @NAMES @DEFAULT_ARGS);
11  
12 use Finance::GeniusTrader::Indicators;
13 use Finance::GeniusTrader::Prices;
14  
15 @ISA = qw(Finance::GeniusTrader::Indicators);
16 @NAMES = ("Range[#*]");
17 @DEFAULT_ARGS = ("{I:Prices HIGH}", "{I:Prices LOW}");
18  
19 =head1 Finance::GeniusTrader::Indicators::Range
20  
21 The range is nothing more than the difference between the high and the low
22 of the day.
23  
24 =cut
25  
26 sub initialize {
27 my ($self) = @_;
28  
29 $self->add_arg_dependency(1,1);
30 $self->add_arg_dependency(2,1);
31 }
32  
33 =head2 Finance::GeniusTrader::Indicators::Range::calculate($calc, $day)
34  
35 =cut
36 sub calculate {
37 my ($self, $calc, $i) = @_;
38 my $name = $self->get_name;
39  
40 return if ($calc->indicators->is_available($name, $i));
41 return if (! $self->check_dependencies($calc, $i));
42
43 my $range = $self->{'args'}->get_arg_values($calc, $i, 1) - $self->{'args'}->get_arg_values($calc, $i, 2);
44  
45 # Return the results
46 $calc->indicators->set($name, $i, $range);
47 }
48  
49 1;