| 1 | package Finance::GeniusTrader::OrderFactory::ChannelBreakout; | ||
| 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 | # Standards-Version: 1.0 | ||
| 8 | |||
| 9 | use strict; | ||
| 10 | use vars qw(@ISA @NAMES @DEFAULT_ARGS); | ||
| 11 | |||
| 12 | use Finance::GeniusTrader::OrderFactory; | ||
| 13 | use Finance::GeniusTrader::Eval; | ||
| 14 | use Finance::GeniusTrader::Indicators qw($GET_LAST); | ||
| 15 | use Finance::GeniusTrader::Tools qw(:generic); | ||
| 16 | |||
| 17 | @ISA = qw(Finance::GeniusTrader::OrderFactory); | ||
| 18 | @NAMES = ("ChannelBreakout[#*]"); | ||
| 19 | @DEFAULT_ARGS = (); | ||
| 20 | |||
| 21 | =head1 NAME | ||
| 22 | |||
| 23 | Finance::GeniusTrader::OrderFactory::ChannelBreakout | ||
| 24 | |||
| 25 | =head1 DESCRIPTION | ||
| 26 | |||
| 27 | This module is able to set up a generic channel breakout strategy based on | ||
| 28 | two generic limited price order, above and below current prices. Both | ||
| 29 | levels will be defined with an indicator. | ||
| 30 | |||
| 31 | =cut | ||
| 32 | |||
| 33 | sub initialize { | ||
| 34 | my ($self) = @_; | ||
| 35 | |||
| 36 | $self->add_arg_dependency(1, 1) unless $self->{'args'}->is_constant(1); | ||
| 37 | $self->add_arg_dependency(2, 1) unless $self->{'args'}->is_constant(2); | ||
| 38 | } | ||
| 39 | |||
| 40 | sub create_buy_order { | ||
| 41 | my ($self, $calc, $i, $sys_manager, $pf_manager) = @_; | ||
| 42 | |||
| 43 | return 0 if (! $self->check_dependencies($calc, $i)); | ||
| 44 | |||
| 45 | my $price = $self->{'args'}->get_arg_values($calc, $i, 1); | ||
| 46 | return $pf_manager->buy_conditional($calc, $sys_manager->get_name, $price); | ||
| 47 | } | ||
| 48 | |||
| 49 | sub create_sell_order { | ||
| 50 | my ($self, $calc, $i, $sys_manager, $pf_manager) = @_; | ||
| 51 | |||
| 52 | return 0 if (! $self->check_dependencies($calc, $i)); | ||
| 53 | |||
| 54 | my $price = $self->{'args'}->get_arg_values($calc, $i, 2); | ||
| 55 | return $pf_manager->sell_conditional($calc, $sys_manager->get_name, $price); | ||
| 56 | } | ||
| 57 | |||
| 58 | 1; |