[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GT] SVN Commit r571 - trunk/GT/Indicators



Author: ras
Date: 2008-03-17 20:11:07 +0100 (Mon, 17 Mar 2008)
New Revision: 571

Added:
   trunk/GT/Indicators/FISH.pm
   trunk/GT/Indicators/FRAMA.pm
   trunk/GT/Indicators/IFISH.pm
   trunk/GT/Indicators/MAMA.pm
   trunk/GT/Indicators/MEAN.pm
Log:
karsten w has implemented these indicators from john ehlers
rocket science for traders




Added: trunk/GT/Indicators/FISH.pm
===================================================================
--- trunk/GT/Indicators/FISH.pm	                        (rev 0)
+++ trunk/GT/Indicators/FISH.pm	2008-03-17 19:11:07 UTC (rev 571)
@@ -0,0 +1,139 @@
+package GT::Indicators::FISH;
+
+# Copyright 2008 Karsten Wippler
+# Based on and for GeniusTrader (C) 2000-2002 Rapha�Hertzog, Fabien Fulhaber
+# This file is distributed under the terms of the General Public License
+# version 2 or (at your option) any later version.
+
+# $Id: FISH.pm,v 1.4 2008/03/14 17:06:09 ras Exp ras $
+
+# Standards-Version: 1.0
+
+use strict;
+use vars qw(@ISA @NAMES @DEFAULT_ARGS);
+
+use GT::ArgsTree;
+use GT::Indicators;
+use GT::Indicators::EMA;
+use GT::Prices;
+
+
AT
ISA = qw(GT::Indicators);
+
AT
NAMES = ("FISH[#1]","RAW[#1]");
+
AT
DEFAULT_ARGS = (10, "{I:MEAN}" );
+
+=head1 GT::Indicators::FISH
+
+=head2 Overview
+Infos cited from chart manual at
+http://www.geocities.com/
+user42_kevin/chart/index.html
+
+The fisher transform indicator by John Ehlers is a range oscillator
+showing where today's price is within the past N-days highest and lowest,
+with some smoothing is used plus what's known in mathematics as a fisher transform.
+This is similar to Stochastics and Williams %R  but the transformation stretches
+values near the high and low, helping to highlight extremes.
+=head2 Calculation
+
+The calculation is as follows. The prices used are the midpoint between the day's
+high and low (as in most of Ehlers' indicators). Today's price is located within
+the highest and lowest of those prices from the past N days, scaled to -1 for the
+low and 1 for the high.
+
+     price = (high + low) / 2
+     
+                 price - Ndaylow
+     raw = 2 * ------------------ - 1
+               Ndayhigh - Ndaylow
+
+This raw position is smoothed by a 5-day EMA and a log form which is the 
+mathematical fisher transform, before a final further 3-day EMA smoothing.
+
+     smoothed = EMA[5] of raw
+     
+                                  1 + smoothed
+     fisher = EMA[3] of 0.5 * log ------------
+                                  1 - smoothed
+
+=head2 Parameters
+
+The standard Fisher-Transform works with a 10-days parameter : n = 10
+
+=head2 Links
+http://mesasoftware.com/technicalpapers.htm
+http://www.geocities.com/user42_kevin/chart/index.html
+
+=head2 Creation
+
+ GT::Indicators::FISH->new()
+ GT::Indicators::FISH->new([20])
+
+If you need a 30 days Fisher Transform of the opening prices you can write
+one of those lines :
+
+ GT::Indicators::FISH->new([30, "{I:Prices OPEN}"])
+
+A 10 days Fisher Transform  of the RSI could be created with :
+
+ GT::Indicators::FISH->new([10, "{I:RSI}"])
+
+
+=cut
+sub initialize {
+    my ($self) = @_;
+    
+    $self->{'ema1'} = GT::Indicators::EMA->new([5,"{I:Generic::Eval ({I:STO/1 ".
+	    $self->{'args'}->get_arg_names(1) . " 1 1 1" .
+	    $self->{'args'}->get_arg_names(2) ."})/50 - 1}" ]);
+
+    $self->{'ema2'} = GT::Indicators::EMA->new([3,"{I:Generic:ByName " . $self->get_name(1) . "}" ]);
+
+
+    # Smoothing functions are args 2 and 3
+    my $nb_days = $self->{'args'}->get_arg_names(1) + 8;
+
+    $self->add_indicator_dependency($self->{'ema1'}, 5);
+    $self->add_arg_dependency(2, $nb_days);
+
+    
+}
+
+=pod
+
+=head2 GT::Indicators::SMI::calculate($calc, $day)
+
+=cut
+
+sub calculate {
+    my ($self, $calc, $i) = @_;
+    my $indic = $calc->indicators;
+    my $prices = $calc->prices;
+    my $ema1_name = $self->{'ema1'}->get_name;
+    my $name = $self->get_name(0);
+    my $raw1_name = $self->get_name(1);
+    
+    return if ($indic->is_available($raw1_name, $i) &&
+	       $indic->is_available($name, $i));
+    return if (! $self->check_dependencies($calc, $i));
+
+    for (my $n = 0; $n < 3; $n++) {
+
+	# Return if RAW1 is available
+	next if $indic->is_available($raw1_name, $i - $n);
+	
+        # Calculate CM
+        my $sraw = $indic->get($ema1_name, $i - $n);
+	my $lraw_value = (abs($sraw) > 0.999) ?
+           $sraw/abs($sraw)*0.999 : $sraw;
+        my $raw1_value = log((1+$lraw_value)/(1-$lraw_value));
+
+	# Return the results
+	$indic->set($raw1_name, $i - $n, $raw1_value);
+    }
+       # Return the results
+       $self->{'ema2'}->calculate($calc, $i);
+       my $fish=$indic->get($self->{'ema2'}->get_name, $i);
+       $indic->set($name, $i, $fish);
+
+}
+1;

Added: trunk/GT/Indicators/FRAMA.pm
===================================================================
--- trunk/GT/Indicators/FRAMA.pm	                        (rev 0)
+++ trunk/GT/Indicators/FRAMA.pm	2008-03-17 19:11:07 UTC (rev 571)
@@ -0,0 +1,204 @@
+package GT::Indicators::FRAMA;
+
+# Copyright 2008 Karsten Wippler
+# Based on and for GeniusTrader (C) 2000-2002 Rapha�Hertzog, Fabien Fulhaber
+# This file is distributed under the terms of the General Public License
+# version 2 or (at your option) any later version.
+
+# $Id: FRAMA.pm,v 1.4 2008/03/14 17:07:14 ras Exp ras $
+
+# Standards-Version: 1.0
+
+use strict;
+use vars qw(@ISA @NAMES @DEFAULT_ARGS);
+
+use GT::Indicators;
+use GT::Indicators::SMA;
+use GT::Indicators::Generic::MinInPeriod;
+use GT::Indicators::Generic::MaxInPeriod;
+
+
AT
ISA = qw(GT::Indicators);
+
AT
NAMES = ("FRAMA[#*]","ALPHA[#1]");
+
AT
DEFAULT_ARGS = (16, "{I:MEAN}");
+
+=head1 NAME
+
+GT::Indicators::FRAMA - FRactal Adaprive Moving Average
+
+=head1 DESCRIPTION
+
+An exponential moving average gives more importance to
+recent prices ... similarly a Frama uses a variable 
+(adaptive) alpha
+
+=head2 Parameters
+
+=over
+
+=item Period (default 20)
+
+The first argument is the period used to calculed the average.
+
+=item Other data input
+
+The second argument is optional. It can be used to specify an other
+stream of input data for the average instead of the close prices.
+This is usually an indicator (detailed via {I:MyIndic <param>}).
+
+=back
+
+=head2 Calculation
+The alpha is calculated following 
+http://www.mesasoftware.com/technicalpapers.htm
+see the self explaining code below :D
+when knowing the alpha FRAMA is
+FRAMA[n] = FRAMA[n-1] + alpha * ( INPUT - FRAMA[n-1] )
+
+In TA, the first value is often constructed as SMA(N).
+
+Note: One criticism could be that the EMA is calculated starting
+from the designated period. But actually the EMA goes all the way back
+to the beginning of the available data. But in all tools I checked they
+start computation from the loaded data on.
+
+=head2 Creation
+
+ GT::Indicators::FRAMA->new()
+ GT::Indicators::FRAMA->new([20])
+
+If you need a 30 days FRAMA of the opening prices you can write
+one of those lines :
+
+ GT::Indicators::FRAMA->new([30, "{I:Prices OPEN}"])
+
+A 10 days EMA of the RSI could be created with :
+
+ GT::Indicators::FRAMA->new([10, "{I:RSI}"])
+
+ note!!! The number of days has to be EVEN!!
+
+Z<>
+
+=cut
+sub initialize {
+    my ($self) = @_;
+    my $period = $self->{'args'}->get_arg_names(1);
+    $period=$period/2;
+    $self->{'hmin'} = GT::Indicators::Generic::MinInPeriod->new([ $period, $self->{'args'}->get_arg_names(2)  ]);
+    $self->{'hmax'} = GT::Indicators::Generic::MaxInPeriod->new([ $period, $self->{'args'}->get_arg_names(2)  ]);
+    $self->{'min'} = GT::Indicators::Generic::MinInPeriod->new([ $self->{'args'}->get_arg_names(1), 
+								 $self->{'args'}->get_arg_names(2)  ]);
+    $self->{'max'} = GT::Indicators::Generic::MaxInPeriod->new([ $self->{'args'}->get_arg_names(1), 
+								 $self->{'args'}->get_arg_names(2)  ]);
+
+    $self->{'sma'} = GT::Indicators::SMA->new([ $self->{'args'}->get_arg_names() ]);
+    $self->add_indicator_dependency($self->{'sma'}, 1);
+    $self->add_indicator_dependency($self->{'hmin'},  $self->{'args'}->get_arg_names(1));
+    $self->add_indicator_dependency($self->{'hmax'},  $self->{'args'}->get_arg_names(1));
+    $self->add_indicator_dependency($self->{'min'},  $self->{'args'}->get_arg_names(1));
+    $self->add_indicator_dependency($self->{'max'},  $self->{'args'}->get_arg_names(1));
+}
+
+sub calculate {
+    my ($self, $calc, $i) = @_;
+    my $indic = $calc->indicators;
+        my $name = $self->get_name(0);
+        my $alpha_name = $self->get_name(1);
+    my $hmin_name = $self->{'hmin'}->get_name;
+    my $hmax_name = $self->{'hmax'}->get_name;
+    my $min_name = $self->{'min'}->get_name;
+    my $max_name = $self->{'max'}->get_name;
+    my $before = 1;
+
+    my $nb = $self->{'args'}->get_arg_values($calc, $i, 1);
+    return if (! defined($nb));
+    my $period=$nb/2;
+
+    return if ($indic->is_available($name, $i));
+    return if ($before && ! $self->check_dependencies($calc, $i));
+
+   my $alpha = 0.5;
+
+    my $oldframa = $indic->get($name, $i - 1);
+    my $frama;
+    if (defined $oldframa) {
+      my $low1 = $indic->get($hmin_name, $i - $period);
+      my $high1 = $indic->get($hmax_name, $i - $period);
+      my $low2 = $indic->get($hmin_name, $i);
+      my $high2 = $indic->get($hmax_name, $i);
+      my $low3 = $indic->get($min_name, $i);
+      my $high3 = $indic->get($max_name, $i);
+      my $N1= ($high1-$low1)/$period;
+      my $N2= ($high2-$low2)/$period;
+      my $N3= ($high3-$low3)/$nb;
+      my $dim;
+      if ($N1>0 && $N2>0 && $N3>0){
+      $dim=(log($N1+$N2)-log($N3))/log(2);
+      }
+      $alpha=exp(-4.6*($dim-1));
+      if ($alpha <0.01){
+      $alpha=0.01;
+      }
+      if ($alpha >1){
+      $alpha=1;
+      }
+      $frama = $alpha * ($self->{'args'}->get_arg_values($calc, $i, 2) - $oldframa) + $oldframa;
+    } else {
+      $frama = $indic->get($self->{'sma'}->get_name, $i);
+      $before = 0;
+    }
+        $indic->set($alpha_name, $i, $alpha);
+    $indic->set($name, $i, $frama);
+
+}
+
+sub calculate_interval {
+    my ($self, $calc, $first, $last) = @_;
+    my $indic = $calc->indicators;
+        my $name = $self->get_name(0);
+        my $alpha_name = $self->get_name(1);
+    my $hmin_name = $self->{'hmin'}->get_name;
+    my $hmax_name = $self->{'hmax'}->get_name;
+    my $min_name = $self->{'min'}->get_name;
+    my $max_name = $self->{'max'}->get_name;
+
+    my $nb = $self->{'args'}->get_arg_constant(1);
+    return if (! defined($nb));
+    return if ($indic->is_available_interval($name, $first, $last));
+    # Don't need to calculate all SMA values, just the first data point.
+        $self->{'sma'}->calculate($calc, $first);
+    return if (! $self->check_dependencies_interval($calc, $first, $last));
+    my $period=$nb/2;
+    my $alpha = 0.5;
+
+    $indic->set($name, $first, $indic->get($self->{'sma'}->get_name, $first));
+
+    for (my $i=$first+1;$i<=$last;$i++) {
+      my $low1 = $indic->get($hmin_name, $i - $period);
+      my $high1 = $indic->get($hmax_name, $i - $period);
+      my $low2 = $indic->get($hmin_name, $i);
+      my $high2 = $indic->get($hmax_name, $i);
+      my $low3 = $indic->get($min_name, $i);
+      my $high3 = $indic->get($max_name, $i);
+      my $N1= ($high1-$low1)/$period;
+      my $N2= ($high2-$low2)/$period;
+      my $N3= ($high3-$low3)/$nb;
+      my $dim;
+      if ($N1>0 && $N2>0 && $N3>0){
+      $dim=(log($N1+$N2)-log($N3))/log(2);
+      }
+      $alpha=exp(-4.6*($dim-1));
+      if ($alpha <0.01){
+      $alpha=0.01;
+      }
+      if ($alpha >1){
+      $alpha=1;
+      }
+      my $oldframa = $indic->get($name, $i - 1);
+      my $frama = $alpha * ($self->{'args'}->get_arg_values($calc, $i, 2) - $oldframa) + $oldframa;
+                $indic->set($alpha_name, $i, $alpha);
+      $indic->set($name, $i, $frama);
+    }
+}
+
+1;

Added: trunk/GT/Indicators/IFISH.pm
===================================================================
--- trunk/GT/Indicators/IFISH.pm	                        (rev 0)
+++ trunk/GT/Indicators/IFISH.pm	2008-03-17 19:11:07 UTC (rev 571)
@@ -0,0 +1,103 @@
+package GT::Indicators::IFISH;
+
+# Copyright 2008 Karsten Wippler
+# Based on and for GeniusTrader (C) 2000-2002 Rapha�Hertzog, Fabien Fulhaber
+# This file is distributed under the terms of the General Public License
+# version 2 or (at your option) any later version.
+
+# $Id: IFISH.pm,v 1.2 2008/03/09 18:06:15 ras Exp ras $
+
+# Standards-Version: 1.0
+
+use strict;
+use vars qw(@ISA @NAMES @DEFAULT_ARGS);
+
+use GT::ArgsTree;
+use GT::Indicators;
+use GT::Indicators::EMA;
+use GT::Prices;
+
+
AT
ISA = qw(GT::Indicators);
+
AT
NAMES = ("IFISH[#1]");
+
AT
DEFAULT_ARGS = (9 , 0.1, 50,"{I:RSI 5}" );
+
+=head1 GT::Indicators::IFISH
+
+=head2 Overview
+Remember The Fisher Transform
+    
+                         1 + x
+     fisher = 0.5 log ------------
+                         1 - x
+ Its inverse is
+
+               exp(2*fisher)-1 
+     ifisher = ----------------
+     	       exp(2*fisher)+1
+
+The input values should lie in the Interval [-5,5]
+so they have to be adjusted to this interval.
+So an Oscillator is moved,scaled,smoothed and  then inverted.
+Ehlers ist using a WMA for the smoothing
+I will use an EMA. 
+
+=head2 Paramters
+
+The User has to input valid scaling parameters.
+for the RSI they are 0.1 and 50 so
+0.1(RSI-50) varies between -5 and 5.
+1. smoothing period
+2. scaling value
+3. midpoint adjustment
+
+
+=head2 Links
+http://mesasoftware.com/technicalpapers.htm
+
+=head2 Creation
+
+ GT::Indicators::IFISH->new()
+
+
+=cut
+sub initialize {
+
+    my ($self) = @_;
+    my $scale = "{I:G:Eval ".  $self->{'args'}->get_arg_names(2) ." * (".
+   		  $self->{'args'}->get_arg_names(4) ." - " . $self->{'args'}->get_arg_names(3) . ")}";
+    $self->{'ema1'} = GT::Indicators::EMA->new([ $self->{'args'}->get_arg_names(1) , $scale ]);
+
+
+
+    # Smoothing functions are args 2 and 3
+    my $nb_days = $self->{'args'}->get_arg_names(1) + $self->{'args'}->get_arg_names(2);
+
+    $self->add_indicator_dependency($self->{'ema1'},$self->{'args'}->get_arg_names(2));
+    $self->add_arg_dependency(5, $nb_days);
+
+    
+}
+
+=pod
+
+=head2 GT::Indicators::SMI::calculate($calc, $day)
+
+=cut
+
+sub calculate {
+    my ($self, $calc, $i) = @_;
+    my $indic = $calc->indicators;
+    my $prices = $calc->prices;
+    my $ema1_name = $self->{'ema1'}->get_name;
+    my $name = $self->get_name(0);
+    
+    return if ($indic->is_available($name, $i));
+    return if (! $self->check_dependencies($calc, $i));
+
+       # Return the results
+       my $input=$self->{'ema1'}->calculate($calc, $i);
+       my $ifish=(exp(2*$input)-1)/(exp(2*$input)+1);
+       $indic->set($name, $i, $ifish);
+
+}
+1;

Added: trunk/GT/Indicators/MAMA.pm
===================================================================
--- trunk/GT/Indicators/MAMA.pm	                        (rev 0)
+++ trunk/GT/Indicators/MAMA.pm	2008-03-17 19:11:07 UTC (rev 571)
@@ -0,0 +1,150 @@
+package GT::Indicators::MAMA;
+
+# Copyright 2008 Karsten Wippler
+# Based on and for GeniusTrader (C) 2000-2002 Rapha�Hertzog, Fabien Fulhaber
+# This file is distributed under the terms of the General Public License
+# version 2 or (at your option) any later version.
+
+# $Id: MAMA.pm,v 1.3 2008/03/14 17:11:16 ras Exp ras $
+
+# Standards-Version: 1.0
+
+use strict;
+use vars qw(@ISA @NAMES @DEFAULT_ARGS);
+
+use GT::Indicators;
+use GT::Indicators::SMA;
+
+
AT
ISA = qw(GT::Indicators);
+
AT
NAMES = ("MAMA[#*]","FAMA[#*]","PERIOD[#*]","ALPHA[#*]");
+
AT
DEFAULT_ARGS = (0.5,0.05,"{I:MEAN}");
+
+=head1 NAME
+
+GT::Indicators::MAMA - Mesa Adaptive Moving Average
+
+=head1 DESCRIPTION
+
+please see Ehlers work
+
+=head2 Parameters
+
+=over
+
+=item Period (default 20)
+
+=head2 Creation
+
+ GT::Indicators::MAMA->new()
+
+=cut
+sub initialize {
+    my ($self) = @_;
+    for (my $i=1;$i<=2;$i++) {
+      die "Argument $i must be a constant value.\n" unless $self->{'args'}->is_constant($i);
+    }
+    $self->{'sma'} = GT::Indicators::SMA->new([9,$self->{'args'}->get_arg_names(3)]);
+    $self->add_indicator_dependency($self->{'sma'}, 29);
+    $self->add_arg_dependency(3, 20);
+}
+
+sub calculate_interval {
+	my ($self, $calc, $first, $last) = @_;
+	my $indic = $calc->indicators;
+	my $mama_name = $self->get_name(0);
+	my $fama_name = $self->get_name(1);
+	my $period_name = $self->get_name(2);
+	my $alpha_name = $self->get_name(3);
+	my $alpha = 0.5;
+	my @smooth=(0,0,0,0,0,0,0);
+	my @detrend=(0,0,0,0,0,0,0);
+	my @var_Q1=(0,0,0,0,0,0,0);
+	my @var_I1=(0,0,0,0,0,0,0);
+	my $var_JI;
+	my $var_JQ;
+	my @var_I2=(0,0);
+	my @var_Q2=(0,0);
+	my @var_RE=(0,0);
+	my @var_IM=(0,0);
+	my $new;
+	my @temp_period=(0,0);
+	my $pi=3.141592653589793;
+	my @phase=(0,0);
+	my $delta_phase;
+
+	return if ($indic->is_available_interval($mama_name, $first, $last));
+	# Don't need to calculate all SMA values, just the first data point.
+        return if (! $self->check_dependencies_interval($calc, $first, $last));
+	$indic->set($mama_name, $first-18, $indic->get($self->{'sma'}->get_name, $first-18));
+	$indic->set($fama_name, $first-18, $indic->get($self->{'sma'}->get_name, $first-18));
+
+	for (my $i=$first-17;$i<=$last;$i++) {
+		$new=(4*$self->{'args'}->get_arg_values($calc, $i, 3)+
+		      3*$self->{'args'}->get_arg_values($calc, $i-1, 3)+
+		      2*$self->{'args'}->get_arg_values($calc, $i-2, 3)+
+		      1*$self->{'args'}->get_arg_values($calc, $i-3, 3))/10;
+	        unshift(@smooth, $new); pop @smooth;
+		$new=hilbert((@smooth,$temp_period[1]));
+	        unshift(@detrend, $new); pop @detrend;
+		$new=hilbert((@detrend,$temp_period[1]));
+	        unshift(@var_Q1, $new); pop @var_Q1;
+		$new=$detrend[3];unshift(@var_I1, $new); pop @var_I1;
+		$var_JI=hilbert((@var_I1,$temp_period[1]));
+		$var_JQ=hilbert((@var_Q1,$temp_period[1]));
+		$new=$var_I1[0]-$var_JQ;
+	        unshift(@var_I2, $new); pop @var_I2;
+		$var_I2[0]=0.2*$var_I2[0]+0.8*$var_I2[1];
+		$new=$var_Q1[0]+$var_JI;
+	        unshift(@var_Q2, $new); pop @var_Q2;
+		$var_Q2[0]=0.2*$var_Q2[0]+0.8*$var_Q2[1];
+		$new=$var_I2[0]*$var_I2[1]+$var_Q2[0]*$var_Q2[1];
+	        unshift(@var_RE, $new); pop @var_RE;
+		$var_RE[0]=0.2*$var_RE[0]+0.8*$var_RE[1];
+		$new=$var_I2[0]*$var_Q2[1]-$var_Q2[0]*$var_I2[1];
+	        unshift(@var_IM, $new); pop @var_IM;
+		$var_IM[0]=0.2*$var_IM[0]+0.8*$var_IM[1];
+		if ($var_RE[0] != 0 && $var_IM[0] != 0){
+		$new=atan2($var_IM[0],$var_RE[0]);
+		$new=$new*180/$pi;
+		$new=360/$new;
+		}
+	        unshift(@temp_period, $new); pop @temp_period;
+		if ($temp_period[0]>1.5*$temp_period[1]){$temp_period[0]=1.5*$temp_period[1];}
+		if ($temp_period[0]<0.67*$temp_period[1]){$temp_period[0]=0.67*$temp_period[1];}
+		if ($temp_period[0]<6){$temp_period[0]=6;}
+		if ($temp_period[0]>50){$temp_period[0]=50;}
+		$temp_period[0]=0.2*$temp_period[0]+0.8*$temp_period[1];
+		$indic->set($period_name, $i, $temp_period[0]);
+		if($var_I1[0] !=0){
+			$new=atan2($var_Q1[0],$var_I1[0]);
+			$new=$new*180/$pi;
+		} else {
+		$new=0;
+		}
+	        unshift(@phase, $new); pop @phase;
+		$delta_phase=$phase[1]-$phase[0];
+		if($delta_phase<1){$delta_phase=1;}
+		$alpha=$self->{'args'}->get_arg_values($calc, $i, 1)/$delta_phase;
+		if($alpha<$self->{'args'}->get_arg_values($calc, $i, 2)){$alpha=$self->{'args'}->get_arg_values($calc, $i, 2);}
+		$indic->set($alpha_name, $i, $alpha);
+		my $oldmama = $indic->get($mama_name, $i - 1);
+		my $oldfama = $indic->get($fama_name, $i - 1);
+		my $mama = $alpha * ($self->{'args'}->get_arg_values($calc, $i, 3) - $oldmama) + $oldmama;
+		my $fama = 0.5*$alpha * ($mama - $oldfama) + $oldfama;
+		$indic->set($mama_name, $i, $mama);
+		$indic->set($fama_name, $i, $fama);
+	}
+
+}
+
+sub hilbert {
+	my (@data) =
AT
_;
+	my ($return_value);
+	my ($const_a) = 0.0962;
+	my ($const_b) = 0.5769;
+	my ($div) = 0.075*$data[7]+0.54;
+	$return_value=($const_a*$data[0]+$const_b*$data[2]-$const_b*$data[4]-$const_a*$data[6])*$div;
+	return $return_value;
+}
+
+1;

Added: trunk/GT/Indicators/MEAN.pm
===================================================================
--- trunk/GT/Indicators/MEAN.pm	                        (rev 0)
+++ trunk/GT/Indicators/MEAN.pm	2008-03-17 19:11:07 UTC (rev 571)
@@ -0,0 +1,60 @@
+package GT::Indicators::MEAN;
+
+# Copyright 2008 Karsten Wippler
+# Based on and for GeniusTrader (C) 2000-2002 Rapha�Hertzog, Fabien Fulhaber
+# This file is distributed under the terms of the General Public License
+# version 2 or (at your option) any later version.
+
+# $Id: MEAN.pm,v 1.1 2008/03/14 16:53:45 ras Exp $
+
+# Standards-Version: 1.0
+
+use strict;
+use vars qw(@ISA @NAMES @DEFAULT_ARGS);
+
+use GT::Indicators;
+use GT::Prices;
+
+
AT
ISA = qw(GT::Indicators);
+
AT
NAMES = ("MEAN[#1,#2]");
+
AT
DEFAULT_ARGS=("{I:Prices HIGH}", "{I:Prices LOW}");
+
+=head1 GT::Indicators::WTCL
+
+=head2 Overview
+
+The mean indicator is simply an average of each days high and low. 
+
+=head2 Calculation
+
+mean =(high+low)/2
+
+=head2 Links
+
+=cut
+
+sub initialize {
+    my ($self) = @_;
+    $self->add_arg_dependency(1, 1);
+    $self->add_arg_dependency(2, 1);
+}
+
+=head2 GT::Indicators::WTCL::calculate($calc, $day)
+
+=cut
+sub calculate {
+    my ($self, $calc, $i) = @_;
+    my $name = $self->get_name;
+    my $prices = $calc->prices;
+
+    return if ($calc->indicators->is_available($name, $i));
+    return if (! $self->check_dependencies($calc, $i));
+
+    my $mean = (( $self->{'args'}->get_arg_values($calc, $i, 1) + 
+		  $self->{'args'}->get_arg_values($calc, $i, 2) ) 
+		   /2 );
+
+    $calc->indicators->set($name, $i, $mean);
+}
+
+1;