Thursday, April 30, 2009

Dr. Brett's "Strong Day" Indicator

Dr. Steenbarger over at TraderFeed proposed a simple hypothesis: momentum is a leading indicator of price.

I built his proposed indicator using GeniusTrader (an open source system).

Here's my version of his original plot:Rather than sum the "strong days" I take a moving average over 20 days. So a value of 0.5 on the indicator is equivalent to 10 strong days.

Here's the perl module I created to add this indicator to GT:
package GT::Indicators::StrongDay;
use strict;
use vars qw(@ISA @NAMES @DEFAULT_ARGS);

use GT::Indicators;
use GT::Prices;

@ISA = qw(GT::Indicators);
@NAMES = ("StrongDay[#1,#2,#3]");
@DEFAULT_ARGS = ("{I:Prices HIGH}", "{I:Prices LOW}", "{I:Prices CLOSE}");

sub initialize {
my ($self) = @_;
$self->add_arg_dependency(1, 1);
$self->add_arg_dependency(2, 1);
$self->add_arg_dependency(3, 1);
}

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);

my $strong = ($self->{'args'}->get_arg_values($calc, $i, 3) > $mean) ? 1 : 0;

$calc->indicators->set($name, $i, $strong);
}

1;

0 comments:

Post a Comment