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

Re: [GT] DSS



Hi Ras,

could you please send me you display_indicator.pl

tia,

Karsten

On Sat, 2008-02-23 at 09:22 -0800, Robert A. Schmied wrote:
> kw wrote:
> > Hallo RAS, Hello all,
> > 
> > I'm still trying to fix the DSS, so I took the old DSS and the similar
> > calls in the definition of TRIX. Now I got stuck, no errors but no
> > indicator as well. I'm quite sure there is only a silly mistake
> > preventing it from working. I attached my wannabe-fixed DSS.
> > 
> > 
> > cheers,
> > 
> > Karsten
> 
> aloha Karsten
> 
> i'm attaching my hacked up version -- didn't change much (anything) of
> significance, just reformatted (80 columns) and added loads of progress
> prints.
> 
> i haven't looked at what dss is since reference url link is in german
> and (in spite of my name i don't speak or read german), but looking
> at the pod i'm gonna guess that dss should output 3 values p1, p2 and p3.
> 
> also, looking at sto (Stochastic Oscillator) code, also mentioned in the pod,
> it looks to me like the code needs to define $self->{'p1'}, $self->{'p2'}, $self->{'p3'}
> plus some of the other intermediate values in the initialize method, then
> assign values in the calulate method.
> 
> i'd make extensive use of the sto code as an operational example.
> 
> note that somehow the overall gt code connects the values in @NAMES with
> the values being calculated (via array indices and calls to $self->get_name).
> so three names need to be assigned.
> 
> good luck -- post if you run into additional troubles
> 
> ras
> 
> ps -- using my (hopefully very much like current version of display_indicator.pl)
> ras [ 3810 ] %     display_indicator.pl --timeframe day --start 11feb08  --end yesterday I:STO T
> Indicator I:STO has 4 values ... all values selected
>         I:STO/1  <=> %K Fast[5]
>         I:STO/2  <=> %D Fast[5,3]
>         I:STO/3  <=> %K Slow[5,3]
>         I:STO/4  <=> %D Slow[5,3,3]
> 
>         timeframe day, time periods 2293 .. 2301
> Calculating all 4 indicators ...
> %K Fast[5]          [2008-02-11] = 48.5781
> %D Fast[5,3]        [2008-02-11] = 33.2050
> %K Slow[5,3]        [2008-02-11] = 33.2050
> %D Slow[5,3,3]      [2008-02-11] = 22.5258
> .
> .
> .
> 
> and
> ras [ 3813 ] %    !!
> display_indicator.pl --timeframe day --start 11feb08 --end yesterday I:DSSplus T
> Indicator I:DSSplus has 1 value ... all values selected
>         I:DSSplus/1  <=> DSS-BLAU[3,3,1,{I:Prices CLOSE}]
> 
>         timeframe day, time periods 2293 .. 2301
> Calculating indicator ...
> dssplus: nb1=3 nb2=3 nb3=1
>         Calculate the dependencies
>         rtn=0
>         rtn=1
>         rtn=1
>         rtn=1
>         humm, calc=GT::Calculator=HASH(0x8a0ed8), name=DSS-BLAU[3,3,1,{I:Prices CLOSE}] i=2293 not available
> .
> .
> .
> 
> here's the hacked GT:I:DSSplus
> package GT::Indicators::DSSplus;
> 
> # Copyright 2002 Oliver Bossert
> # This file is distributed under the terms of the General Public License
> # version 2 or (at your option) any later version.
> 
> # 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::Indicators::Generic::Divide;
> 
> #use Data::Dumper;
> 
> 
> @ISA = qw(GT::Indicators);
> @NAMES = ("DSS-BLAU[#*]");
> @DEFAULT_ARGS = (3,3,1,"{I:Prices CLOSE}");
> 
> =head1 NAME
> 
> GT::Indicators::DSS - The Double Smoothed Stochastic (William Blau)
> 
> =head1 DESCRIPTION 
> 
> The DSS is calculated as follows:
> 
>   DSS (p1, p2, p3) = EMA( EMA( Close - Lowest(p1), p2), p3 ) /
>                           EMA( EMA( Highest(p1) - Lowest(p1), p2), p3 ) /
> 
> The handling and the calculations of signals is similar to the
> Stochastic-Indictor.
> 
> =head2 Parameters
> 
> =over
> 
> =item Period 1 (default 3)
> 
> The period of the minimum/maximum.
> 
> =item Period 2 (default 3)
> 
> The period of the first EMA
> 
> =item Period 3 (default 1)
> 
> The period of the second EMA
> 
> =item Source 
> 
> The source of which the indicators is calculated.
> 
> =back
> 
> =head2 Creation
> 
> 
> =head2 Link
> 
> This link is unfortunately only in german:
> 
> http://www.trading-konzepte.de/indikator/dss-blau.htm
> 
> =cut
> 
> 
> sub initialize {
>     my ($self) = @_;
> 
>     my $hhigh = "{Indicators::Generic::MaxInPeriod "
>               .       $self->{'args'}->get_arg_names(1)
>               . " " . $self->{'args'}->get_arg_names(4)
>               . "}";
>     my $llow = "{Indicators::Generic::MinInPeriod "
>              .       $self->{'args'}->get_arg_names(1)
>              . " " . $self->{'args'}->get_arg_names(4)
>              . "}";
>     my $diff1 = "{Indicators::Generic::Eval "
>               . $self->{'args'}->get_arg_names(4)
>               . " - "
>                 . $llow . "}";
>     my $diff2 = "{Indicators::Generic::Eval "
>               . $hhigh
>               . " - "
>               . $llow . "}";
> 
>     $self->{'div'} = GT::Indicators::Generic::Divide->new(
>      [ $diff1, $diff2 ] );
>     $self->{'ema1'} = GT::Indicators::EMA->new(
>      [ $self->{'args'}->get_arg_names(2),
>       "{ I:EMA @{ [$self->{'div'}->{'args'}->get_arg_names()] } }" ]
>     );
>     $self->{'ema2'} = GT::Indicators::EMA->new(
>      [ $self->{'args'}->get_arg_names(3),
>       "{ I:EMA @{ [$self->{'ema1'}->{'args'}->get_arg_names()] } }" ]
>      );
> }
> 
> sub calculate {
>     my ($self, $calc, $i) = @_;
>     my $indic = $calc->indicators;
>     my $name = $self->get_name();
>     my $nb1 = $self->{'args'}->get_arg_values($calc, $i, 1);
>     my $nb2 = $self->{'args'}->get_arg_values($calc, $i, 2);
>     my $nb3 = $self->{'args'}->get_arg_values($calc, $i, 3);
> 
> print STDERR "dssplus: nb1=$nb1 nb2=$nb2 nb3=$nb3\n";
> #print STDERR Dumper $self;
> 
>     return if (!defined($nb1) || !defined($nb2) || !defined($nb3) );
> 
> print STDERR "\tCalculate the dependencies\n";
>     # Calculate the dependencies
>     my $rtn = $self->remove_volatile_dependencies();
> print STDERR "\trtn=$rtn\n";
>     $rtn = $self->add_volatile_indicator_dependency(
>      $self->{'div'}, $nb1 * 3 - 2);
> print STDERR "\trtn=$rtn\n";
>     $self->add_volatile_indicator_dependency( $self->{'ema1'}, $nb2 * 2 - 1 );
> print STDERR "\trtn=$rtn\n";
>     $self->add_volatile_indicator_dependency( $self->{'ema2'}, $nb3 );
> print STDERR "\trtn=$rtn\n";
> 
>     return if ($calc->indicators->is_available($name, $i));
> print STDERR "\thumm, calc=$calc, name=$name i=$i not available\n";
>     return if (! $self->check_dependencies($calc, $i));
> print STDERR "\thumm, calc=$calc, i=$i ok\n";
> 
>     my $dss = $indic->get($self->{'ema2'}->get_name, $i);
> print STDERR "\twell dss(i) is $dss($i)\n";
> 
>     $indic->set($name, $i, $dss);
> }
> 
> 1;