| 1 | package Finance::GeniusTrader::Indicators::Generic::Min; | ||
| 2 | |||
| 3 | # Copyright 2000-2002 Raphaƫl Hertzog | ||
| 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 | # Standards-Version: 1.0 | ||
| 8 | |||
| 9 | use strict; | ||
| 10 | use vars qw(@ISA @NAMES); | ||
| 11 | |||
| 12 | use Finance::GeniusTrader::Indicators; | ||
| 13 | use Finance::GeniusTrader::Prices; | ||
| 14 | use Finance::GeniusTrader::Tools qw(:math); | ||
| 15 | |||
| 16 | @ISA = qw(Finance::GeniusTrader::Indicators); | ||
| 17 | @NAMES = ("Min[#*]"); | ||
| 18 | |||
| 19 | =head1 NAME | ||
| 20 | |||
| 21 | Finance::GeniusTrader::Indicators::Generic::Min - Return the minimum of all parameters | ||
| 22 | |||
| 23 | =head1 DESCRIPTION | ||
| 24 | |||
| 25 | This indicator returns the smallest value of all its parameters. | ||
| 26 | |||
| 27 | =cut | ||
| 28 | sub initialize { | ||
| 29 | my ($self) = @_; | ||
| 30 | |||
| 31 | } | ||
| 32 | |||
| 33 | sub calculate { | ||
| 34 | my ($self, $calc, $i) = @_; | ||
| 35 | my $name = $self->get_name; | ||
| 36 | |||
| 37 | return if ($calc->indicators->is_available($name, $i)); | ||
| 38 | |||
| 39 | my $res = $self->{'args'}->get_arg_values($calc, $i, 1); | ||
| 40 | my $expr = ""; | ||
| 41 | for (my $n = 2; $n <= $self->{'args'}->get_nb_args(); $n++) { | ||
| 42 | my $val = $self->{'args'}->get_arg_values($calc, $i, $n); | ||
| 43 | if (defined($val)) { | ||
| 44 | $res = min($res, $val); | ||
| 45 | } | ||
| 46 | } | ||
| 47 | |||
| 48 | if (defined($res)) { | ||
| 49 | $calc->indicators->set($name, $i, $res); | ||
| 50 | } | ||
| 51 | } |