| 1 | package Finance::GeniusTrader::Signals::Prices::Unchange; | ||
| 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 = ("Unchange"); | ||
| 17 | @DEFAULT_ARGS = (); | ||
| 18 | |||
| 19 | =head1 NAME | ||
| 20 | |||
| 21 | Finance::GeniusTrader::Signals::Unchange | ||
| 22 | |||
| 23 | =head1 DESCRIPTION | ||
| 24 | |||
| 25 | The Unchange Signal will be able to tell you if a security is unchange or not from the previous period. | ||
| 26 | |||
| 27 | Advance, Decline and Unchange Signals are basics signals and will be your row materials for designing lots of market indicators. | ||
| 28 | |||
| 29 | =cut | ||
| 30 | sub initialize { | ||
| 31 | my ($self) = @_; | ||
| 32 | |||
| 33 | $self->add_prices_dependency(2); | ||
| 34 | } | ||
| 35 | |||
| 36 | sub detect { | ||
| 37 | my ($self, $calc, $i) = @_; | ||
| 38 | my $q = $calc->prices; | ||
| 39 | |||
| 40 | return if ($calc->signals->is_available($self->get_name, $i)); | ||
| 41 | return if (! $self->check_dependencies($calc, $i)); | ||
| 42 | |||
| 43 | # We're not moving ! | ||
| 44 | if ( $q->at($i)->[$LAST] == $q->at($i-1)->[$LAST] ) { | ||
| 45 | $calc->signals->set($self->get_name, $i, 1); | ||
| 46 | } else { | ||
| 47 | $calc->signals->set($self->get_name, $i, 0); | ||
| 48 | } | ||
| 49 | } | ||
| 50 | |||
| 51 | 1; |