GeniusTrader/Signals/Generic/Not.pm untested

filter: Statementstmt 0.0% 0 / 21 Branchbran 0.0% 0 / 8 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 5 Podpod 0.0% 0 / 2 totaltotal 0.0% 0 / 36 CC 5 SCAR 23.9
CC
5
Cov
0%
detect
20.0
initialize
6.0
BEGIN
2.0
CRAP 10.9
1 package Finance::GeniusTrader::Signals::Generic::Not;
2  
3 # Copyright 2004 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::Signals;
13  
14 @ISA = qw(Finance::GeniusTrader::Signals);
15 @NAMES = ("Not[#*]");
16  
17 =head1 Not Signal Negation
18  
19 =head2 Overview
20  
21 This Generic Signal will reverse the value of the
22 signal parameter it receives.
23  
24 =head2 EXAMPLE
25  
26 You can use this signal to check if the closing prices
27 are not decreasing:
28  
29 S:Generic:Not {S:Generic:Decrease {I:Prices CLOSE}}
30  
31 =cut
32 sub initialize {
33 my ($self) = @_;
34 warn "Bad number of arguments given to S:Generic:Not !" if ($self->{'args'}->get_nb_args() != 1);
35 }
36  
37 sub detect {
38 my ($self, $calc, $i) = @_;
39 my $signals = $calc->signals;
40  
41 return if ($calc->signals->is_available($self->get_name, $i));
42 my $value = $self->{'args'}->get_arg_values($calc, $i, 1);
43 return if (! defined($value));
44 if ($value) {
45 $signals->set($self->get_name, $i, 0);
46 } else {
47 $signals->set($self->get_name, $i, 1);
48 }
49 }
50  
51 1;