GeniusTrader/Signals/Generic/Or.pm untested

filter: Statementstmt 0.0% 0 / 35 Branchbran 0.0% 0 / 10 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 7 Podpod 0.0% 0 / 2 totaltotal 0.0% 0 / 54 CC 6 SCAR 26.6
CC
6
Cov
0%
detect
30.0
initialize
6.0
BEGIN
2.0
CRAP 14.3
1 package Finance::GeniusTrader::Signals::Generic::Or;
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);
11  
12 use Finance::GeniusTrader::Signals;
13 use Finance::GeniusTrader::Eval;
14 use Finance::GeniusTrader::Tools qw(:generic);
15  
16 @ISA = qw(Finance::GeniusTrader::Signals);
17 @NAMES = ("Or[#*]");
18  
19 =head1 Or Combination Signals
20  
21 =head2 Overview
22  
23 This Generic Signal will be give a positive signals when anyone of the
24 mentionned signals also give a positive signal.
25  
26 =head2 EXAMPLE
27  
28 You can use this signal to check if the closing prices is below
29 10 or above 15 :
30  
31 S:Generic:Or {S:Generic:Below {I:Prices CLOSE} 10} {S:Generic:Above {I:Prices CLOSE} 15}
32  
33 =cut
34 sub initialize {
35 my ($self) = @_;
36 warn "Bad number of arguments given to S:Generic:Or !" if ($self->{'args'}->get_nb_args() < 2);
37 }
38  
39 sub detect {
40 my ($self, $calc, $i) = @_;
41 my $signals = $calc->signals;
42
43 return if ($calc->signals->is_available($self->get_name, $i));
44  
45 my $defined = 0;
46 for (my $n = 1; $n <= $self->{'args'}->get_nb_args; $n++)
47 {
48 my $value = $self->{'args'}->get_arg_values($calc, $i, $n);
49 next if (! defined($value));
50 $defined = 1;
51 if ($value) {
52 $signals->set($self->get_name, $i, 1);
53 return;
54 }
55 }
56 if ($defined) {
57 $signals->set($self->get_name, $i, 0);
58 }
59 }
60  
61 1;