GeniusTrader/Signals/Prices/GapDown.pm untested

filter: Statementstmt 0.0% 0 / 25 Branchbran 0.0% 0 / 6 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 6 Podpod 0.0% 0 / 2 totaltotal 0.0% 0 / 39 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::GapDown;
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 use strict;
8 use vars qw(@ISA @NAMES @DEFAULT_ARGS);
9  
10 # Standards-Version: 1.0
11  
12 use Finance::GeniusTrader::Signals;
13 use Finance::GeniusTrader::Prices;
14  
15 @ISA = qw(Finance::GeniusTrader::Signals);
16 @NAMES = ("GapDown[#1]");
17 @DEFAULT_ARGS = (0);
18  
19 =head1 NAME
20  
21 Finance::GeniusTrader::Signals::GapDown
22  
23 =head1 DESCRIPTION
24  
25 Gaps form when opening price movements create a blank spot on the chart.
26 Gaps are especially significant when accompanied by an increase of volume.
27  
28 A down gap forms when a security opens below previous period's low, remains
29 below the previous low for the entire period and close below it.
30  
31 Down gaps can form on daily, weekly or monthly charts and are generally considered bearish.
32  
33 =cut
34  
35 sub initialize {
36 my ($self) = @_;
37
38 $self->add_prices_dependency(2);
39 }
40  
41 sub detect {
42 my ($self, $calc, $i) = @_;
43 my $q = $calc->prices;
44 my $percentage = ($self->{'args'}->get_arg_values($calc, $i, 1) / 100);
45  
46 return if ($calc->signals->is_available($self->get_name, $i));
47 return if (! $self->check_dependencies($calc, $i));
48
49 # A Gap Down appears when the highest price of the period
50 # is below the lowest price of the previous period.
51 if ( $q->at($i)->[$HIGH] < ($q->at($i-1)->[$LOW] * (1 - $percentage))) {
52 $calc->signals->set($self->get_name, $i, 1);
53 } else {
54 $calc->signals->set($self->get_name, $i, 0);
55 }
56 }
57  
58 1;