GeniusTrader/Signals/Graphical/CandleSticks/BearishEngulfingLine.pm untested

filter: Statementstmt 0.0% 0 / 38 Branchbran 0.0% 0 / 8 Conditioncond 0.0% 0 / 18 MC/DCmcdc 0.0% 0 / 8 Subroutinesub 0.0% 0 / 8 Podpod 0.0% 0 / 3 totaltotal 0.0% 0 / 83 CC 5 SCAR 21.6
CC
5
Cov
0%
detect
20.0
new
6.0
initialize
2.0
CRAP 8.7
1 package Finance::GeniusTrader::Signals::Graphical::CandleSticks::BearishEngulfingLine;
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);
9  
10 use Finance::GeniusTrader::Signals;
11 use Finance::GeniusTrader::Prices;
12 use Finance::GeniusTrader::Indicators::CNDL;
13  
14 @ISA = qw(Finance::GeniusTrader::Signals);
15 @NAMES = ("BearishEngulfingLine");
16  
17 =head1 Finance::GeniusTrader::Signals::Graphical::CandleSticks::BearishEngulfingLine
18  
19 =head2 Overview
20  
21 The Bearish Engulfing Line is a strongly bearish if it occurs after a significant up-trend (i.e., it acts as a reversal pattern). It occurs when a small bullish (empty) line is engulfed by a large bearish (filled-in) line.
22  
23 Engulfing Lines are one of the most important and powerful candle patterns. To form the pattern, today's range encloses or "engulfs" the
24 prior day's range, thereby indicating great market strength in the direction of today's close.
25  
26 From a psychological perspective, Engulfing Lines indicate that the market opened in the same direction as the prior day, but then reversed sentiment to close strongly in the opposite direction, overcoming and reversing yesterday's assumption regarding value.
27  
28 =head2 Construction
29  
30 If yesterday closed lower, a Bullish Engulfing Line will form when today's open is below yesterday's close abd today's close is above yesterday's open. The Bearish Line is just the opposite, where a black body enckises a previous white body.
31  
32 =head2 Representation
33  
34 |
35 ###
36 _|_ ###
37 | | ###
38 |___| ###
39 | ###
40 ###
41 |
42  
43 Bearish Engulfing Line
44  
45 =head2 Links
46  
47 http://www.equis.com/free/taaz/candlesticks.html
48  
49 =cut
50  
51 sub new {
52 my $type = shift;
53 my $class = ref($type) || $type;
54 my $args = shift;
55  
56 my $self = { "args" => defined($args) ? $args : [] };
57
58 return manage_object(\@NAMES, $self, $class, $self->{'args'}, "");
59 }
60  
61 sub initialize {
62 my ($self) = @_;
63
64 $self->{'cndl'} = Finance::GeniusTrader::Indicators::CNDL->new($self->{'args'});
65  
66 $self->add_indicator_dependency($self->{'cndl'}, 2);
67 }
68  
69 sub detect {
70 my ($self, $calc, $i) = @_;
71 my $prices = $calc->prices;
72 my $cndl_name = $self->{'cndl'}->get_name(0);
73 my $bearish_engulfing_line_name = $self->get_name(0);;
74  
75 return if ($calc->signals->is_available($self->get_name(0), $i));
76 return if (! $self->check_dependencies($calc, $i));
77
78 my $previous_cndl_code = $calc->indicators->get($cndl_name, $i - 1);
79 my $cndl_code = $calc->indicators->get($cndl_name, $i);
80  
81 # Previous CandleCode from 80 to 111
82 # CandleCode from 0 to 15
83 if (($previous_cndl_code >= 80) and ($previous_cndl_code <= 111) and
84 ($cndl_code >= 0) and ($cndl_code <= 15) and
85 ($prices->at($i)->[$OPEN] > $prices->at($i - 1)->[$CLOSE]) and
86 ($prices->at($i)->[$CLOSE] < $prices->at($i - 1)->[$OPEN])
87 )
88 {
89 $calc->signals->set($bearish_engulfing_line_name, $i, 1);
90 } else {
91 $calc->signals->set($bearish_engulfing_line_name, $i, 0);
92 }
93 }
94  
95 1;