GeniusTrader/Indicators/PFE.pm untested

filter: Statementstmt 0.0% 0 / 34 Branchbran 0.0% 0 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 7 Podpod 0.0% 0 / 2 totaltotal 0.0% 0 / 47 CC 3 SCAR 16.7
CC
3
Cov
0%
calculate
12.0
initialize
2.0
BEGIN
2.0
CRAP 5.3
1 package Finance::GeniusTrader::Indicators::PFE;
2  
3 # Copyright 2002 Oliver Bossert
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::ArgsTree;
13 use Finance::GeniusTrader::Indicators;
14 use Finance::GeniusTrader::Indicators::EMA;
15  
16 @ISA = qw(Finance::GeniusTrader::Indicators);
17 @NAMES = ("PFE[#*]");
18 @DEFAULT_ARGS = (10,5,2,1,"{I:Prices CLOSE}");
19  
20 =head1 NAME
21  
22 Finance::GeniusTrader::Indicators::PFE - Polarized Fractal Efficiency
23  
24 =head1 DESCRIPTION
25  
26  
27 =head2 Parameters
28  
29 =over
30  
31 =item Period (default 10)
32  
33 The first argument is the period used to calculed the average.
34  
35 =item Period 2 (default 5)
36  
37 Period in which the EMA is calculated.
38  
39 =item Exponent (default 2)
40  
41 =item Correction-Factor (default 1)
42  
43 Set this factor to 200 for values > 1000
44  
45 =item Datasource
46  
47 =back
48  
49 =head2 Creation
50  
51  
52 =head2 Link
53  
54  
55 =cut
56  
57  
58 sub initialize {
59 my ($self) = @_;
60 my $pfe = "{I:PFEraw " . $self->{'args'}->get_arg_names(1) . " " .$self->{'args'}->get_arg_names(3) . " " .
61 $self->{'args'}->get_arg_names(4) . " " . $self->{'args'}->get_arg_names(5) . "}";
62  
63 $self->{'ema'} = Finance::GeniusTrader::Indicators::EMA->new([$self->{'args'}->get_arg_names(2), $pfe]);
64
65 }
66  
67 sub calculate {
68 my ($self, $calc, $i) = @_;
69 my $indic = $calc->indicators;
70 my $name = $self->get_name(0);
71 my $length = $self->{'args'}->get_arg_values($calc, $i, 1);
72  
73 $self->remove_volatile_dependencies();
74 $self->add_volatile_arg_dependency(5, $length);
75 $self->add_volatile_indicator_dependency($self->{'ema'}, $length);
76 return if ($calc->indicators->is_available($name, $i));
77 return if (! $self->check_dependencies($calc, $i));
78  
79 my $pfe = $calc->indicators->get($self->{'ema'}->get_name(0), $i);
80 $indic->set($name, $i, $pfe);
81 }
82  
83 1;