GeniusTrader/Signals/Prices/InsidePrevious.pm untested

filter: Statementstmt 0.0% 0 / 24 Branchbran 0.0% 0 / 6 Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 0.0% 0 / 6 Podpod 0.0% 0 / 2 totaltotal 0.0% 0 / 43 CC 4 SCAR 23.0
CC
4
Cov
0%
detect
20.0
initialize
2.0
BEGIN
2.0
CRAP 10.0
1 package Finance::GeniusTrader::Signals::Prices::InsidePrevious;
2  
3 # Copyright 2003 Alexander Henkel
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::Prices;
14  
15 @ISA = qw(Finance::GeniusTrader::Signals);
16 @NAMES = ("InsidePrevious");
17  
18 =head1 Finance::GeniusTrader::Signals::Prices::InsidePrevious
19  
20 The InsidePrevious signal gets triggered if a security's high is lower than or equal to
21 the previous period's high, and the low is higher than or equal to previous period's
22 low.
23  
24 =cut
25 sub initialize {
26 my ($self) = @_;
27
28 $self->add_prices_dependency(2);
29 }
30  
31 sub detect {
32 my ($self, $calc, $i) = @_;
33 my $q = $calc->prices;
34  
35 return if ($calc->signals->is_available($self->get_name, $i));
36 return if (! $self->check_dependencies($calc, $i));
37
38 # Check on Inside Day
39 if ( ($q->at($i)->[$HIGH] <= $q->at($i-1)->[$HIGH]) &&
40 ($q->at($i)->[$LOW] >= $q->at($i-1)->[$LOW]) ) {
41 $calc->signals->set($self->get_name, $i, 1);
42 }
43 else {
44 $calc->signals->set($self->get_name, $i, 0);
45 }
46 }
47  
48 1;