GeniusTrader/Indicators/ChaikinsVola.pm untested

filter: Statementstmt 0.0% 0 / 38 Branchbran 0.0% 0 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 9 Podpod 0.0% 0 / 2 totaltotal 0.0% 0 / 53 CC 3 SCAR 15.5
CC
3
Cov
0%
calculate
12.0
initialize
2.0
BEGIN
2.0
CRAP 4.7
1 package Finance::GeniusTrader::Indicators::ChaikinsVola;
2  
3 # Copyright 2002 Oliver Bossert
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 use Finance::GeniusTrader::Tools qw(:math);
15 use Finance::GeniusTrader::ArgsTree;
16 use Finance::GeniusTrader::Indicators::ROC;
17  
18 @ISA = qw(Finance::GeniusTrader::Indicators);
19 @NAMES = ("ChaikinsVola[#*]");
20 @DEFAULT_ARGS = (10,10,"{I:Prices HIGH}","{I:Prices LOW}");
21  
22 =head1 NAME
23  
24 Finance::GeniusTrader::Indicators::ChaikinsVola - Chaikins Volatility
25  
26 =head1 DESCRIPTION
27  
28 This is calculated as the Rate of change of an Moving Average of the
29 difference between High and Low.
30  
31 =head2 Parameters
32  
33 =over
34  
35 =item Period 1
36  
37 The Period used for the ROC.
38  
39 =item Period 2
40  
41 The Period used for the MA.
42  
43 =item High
44  
45 =item Low
46  
47 =back
48  
49 =cut
50  
51  
52 sub initialize {
53 my $self = shift;
54 my $diff = "{I:Generic::Eval " . $self->{'args'}->get_arg_names(3). " - " .
55 $self->{'args'}->get_arg_names(4) . "}";
56 my $sma = "{I:SMA " . $self->{'args'}->get_arg_names(2) . " " . $diff . "}";
57  
58 $self->{'roc'} = Finance::GeniusTrader::Indicators::ROC->new( [ $self->{'args'}->get_arg_names(1), $sma ]);
59 $self->add_indicator_dependency($self->{'roc'}, 1);
60 }
61  
62 sub calculate {
63 my ($self, $calc, $i) = @_;
64 my $indic = $calc->indicators;
65 my $roc = $self->{'roc'}->get_name();
66 my $name = $self->get_name();
67  
68 return if ($calc->indicators->is_available($name, $i));
69 return if (! $self->check_dependencies($calc, $i) );
70  
71 $indic->set($name, $i, $indic->get($roc, $i));
72 }
73  
74 1;