GeniusTrader/Indicators/TP.pm untested

filter: Statementstmt 0.0% 0 / 22 Branchbran 0.0% 0 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 5 Podpod 0.0% 0 / 1 totaltotal 0.0% 0 / 30 CC 2 SCAR 12.0
CC
2
Cov
0%
calculate
6.0
BEGIN
2.0
BEGIN
2.0
CRAP 3.3
1 package Finance::GeniusTrader::Indicators::TP;
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::Indicators;
13 use Finance::GeniusTrader::Prices;
14  
15 @ISA = qw(Finance::GeniusTrader::Indicators);
16 @NAMES = ("TP[#*]");
17 @DEFAULT_ARGS = ("{I:Prices HIGH}", "{I:Prices LOW}", "{I:Prices CLOSE}");
18  
19 =head1 Finance::GeniusTrader::Indicators::TP
20  
21 =head2 Overview
22  
23 The Typical Price indicator provides a simple, single-line plot of the day's average price. Some investors use th Typical Price rather than the closing price when creating moving average penetration systems.
24  
25 The Typical Price is a building block of the Money Flow Index.
26  
27 =head2 Calculation
28  
29 The Typical Price indicator is calculated by adding the high, low and closing prices together, and then dividing by three. The result is the average, or typical price.
30  
31 =head2 Note
32  
33 The Typical Price is sometimes called "Pivot Point".
34  
35 =head2 Validation
36  
37 This indicator is indirectly validatet by I:CCI.
38  
39 =cut
40  
41 =head2 Finance::GeniusTrader::Indicators::TP::calculate($calc, $day)
42  
43 =cut
44 sub calculate {
45 my ($self, $calc, $i) = @_;
46 my $name = $self->get_name;
47 my $prices = $calc->prices;
48  
49 return if ($calc->indicators->is_available($name, $i));
50  
51 # Typical Price = (Today's High + Today's Low + Today's Close ) / 3
52 my $tp = (( $self->{'args'}->get_arg_values($calc, $i, 1) +
53 $self->{'args'}->get_arg_values($calc, $i, 2) +
54 $self->{'args'}->get_arg_values($calc, $i, 3) ) / 3);
55  
56 $calc->indicators->set($name, $i, $tp);
57  
58 }