« GeniusTrader/Signals/Graphical/CandleSticks/Hammer.pm
↑ Summary
GeniusTrader/Indicators/Generic/Diff.pm »
| 1 | package Finance::GeniusTrader::Signals::Graphical::CandleSticks::InvertedHammer; | ||
| 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 = ("InvertedHammer"); | ||
| 16 | |||
| 17 | =head1 Finance::GeniusTrader::Signals::Graphical::CandelSticks::InvertedHammer | ||
| 18 | |||
| 19 | =head2 Overview | ||
| 20 | |||
| 21 | Inverted Hammers are just the opposite of Hammers (see | ||
| 22 | Finance::GeniusTrader::Signals::Graphical::CandleSticks::Hammer), i.e., a small body occurs | ||
| 23 | at the bottom of a long trail. Black Inverted Hammers occuring at the end | ||
| 24 | of uptrends are clearly bearish, since the markets fails in its attempt to | ||
| 25 | rally higher, closing near the open. | ||
| 26 | |||
| 27 | However, white Inverted Hammers at the end of downtrends are more subtle, | ||
| 28 | and it is important to establish the following day as bullish. It is | ||
| 29 | likely that a short-covering rally will ensue, thereby confirming the | ||
| 30 | reversal. | ||
| 31 | |||
| 32 | =head2 Construction | ||
| 33 | |||
| 34 | An inverted Hammer is formed when the open, close and low occur at | ||
| 35 | approximately the same price, with a high extended significantly above the | ||
| 36 | three. The farther away the high is for the day, the more signifiant the | ||
| 37 | pattern in terms of forecasting a reversal. | ||
| 38 | |||
| 39 | =head2 Representation | ||
| 40 | |||
| 41 | |||
| 42 | | | | | | ||
| 43 | | | | | | | | ||
| 44 | | | _|_ _|_ | | | ||
| 45 | | | | | | | ### ### | ||
| 46 | --- --- |___| |___| ### ### | ||
| 47 | | | | | ||
| 48 | |||
| 49 | 79 78 95 94 47 46 | ||
| 50 | |||
| 51 | |||
| 52 | =cut | ||
| 53 | sub new { | ||
| 54 | my $type = shift; | ||
| 55 | my $class = ref($type) || $type; | ||
| 56 | my $args = shift; | ||
| 57 | |||
| 58 | my $self = { "args" => defined($args) ? $args : [] }; | ||
| 59 | |||
| 60 | return manage_object(\@NAMES, $self, $class, $self->{'args'}, ""); | ||
| 61 | } | ||
| 62 | |||
| 63 | sub initialize { | ||
| 64 | my ($self) = @_; | ||
| 65 | |||
| 66 | $self->{'cndl'} = Finance::GeniusTrader::Indicators::CNDL->new($self->{'args'}); | ||
| 67 | |||
| 68 | $self->add_indicator_dependency($self->{'cndl'}, 1); | ||
| 69 | } | ||
| 70 | |||
| 71 | sub detect { | ||
| 72 | my ($self, $calc, $i) = @_; | ||
| 73 | my $cndl_name = $self->{'cndl'}->get_name(0); | ||
| 74 | my $inverted_hammer_name = $self->get_name(0);; | ||
| 75 | |||
| 76 | return if ($calc->signals->is_available($self->get_name(0), $i)); | ||
| 77 | return if (! $self->check_dependencies($calc, $i)); | ||
| 78 | |||
| 79 | my $cndl_code = $calc->indicators->get($cndl_name, $i); | ||
| 80 | |||
| 81 | if (($cndl_code eq 46) or ($cndl_code eq 78) or ($cndl_code eq 94) or | ||
| 82 | ($cndl_code eq 47) or ($cndl_code eq 79) or ($cndl_code eq 95)) { | ||
| 83 | $calc->signals->set($inverted_hammer_name, $i, 1); | ||
| 84 | } else { | ||
| 85 | $calc->signals->set($inverted_hammer_name, $i, 0); | ||
| 86 | } | ||
| 87 | } | ||
| 88 | |||
| 89 | 1; |