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

filter: Statementstmt 0.0% 0 / 39 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 / 84 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::BullishEngulfingLine;
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 = ("BullishEngulfingLine");
16  
17 =head1 Finance::GeniusTrader::Signals::Graphical::CandleSticks::BullishEngulfingLine
18  
19 =head2 Overview
20  
21 The Bullish Engulfing Line is a strongly bullish pattern if it occurs after a significant downtrend (i.e., it acts as a reversal pattern). It occurs when a small bearish (filled-in) line is engulfed by a large bullish (empty) 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 Bullish Engulfing Line
44  
45 =head2 Links
46  
47 http://www.equis.com/free/taaz/candlesticks.html
48  
49 =cut
50 sub new {
51 my $type = shift;
52 my $class = ref($type) || $type;
53 my $args = shift;
54  
55 my $self = { "args" => defined($args) ? $args : [] };
56
57 return manage_object(\@NAMES, $self, $class, $self->{'args'}, "");
58 }
59  
60 sub initialize {
61 my ($self) = @_;
62
63 $self->{'cndl'} = Finance::GeniusTrader::Indicators::CNDL->new($self->{'args'});
64  
65 $self->add_indicator_dependency($self->{'cndl'}, 2);
66 $self->add_prices_dependency(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 $bullish_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 16 to 47
82 # CandleCode from 112 to 127
83 if (($previous_cndl_code >= 16) and ($previous_cndl_code <= 47) and
84 ($cndl_code >= 112) and ($cndl_code <= 127) 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($bullish_engulfing_line_name, $i, 1);
90 } else {
91 $calc->signals->set($bullish_engulfing_line_name, $i, 0);
92 }
93 }
94  
95 1;