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

Re: [amibroker] Re: zig zag question 2



PureBytes Links

Trading Reference Links

Thanks but unfortunately that still isnt what i am looking for...    

Please let me try again...

I am looking for the code for the zig and zag functions...
Here is an example of the code for the stochastic function:

I would define the inputs and the vaiables and the user of this
indicator would see: Stoc(5, 12, 3);

Below I will call the body of the Stochastic function:
------------------------------------------------------------------------
   Inputs: 
   KPeriods(NumericSimple), 
   KSlow(NumericSimple);
Variables: 
   LoLo(0), 
   HiHi(0), 
   HLDIff(0);
LoLo = Lowest(Low, KPeriods);
HiHi = Highest(High, KPeriods);
HLDIff = HiHi - LoLo;

If HLDIff > 0 Then Begin
      If KSlow <= 1 Then
              StochCustom = (Close - LoLo) / HLDIff * 100
      Else
              StochCustom = Average(Close-LoLo,KSlow) /
Average(HLDIff, KSlow)*100;
End;
-----------------------------------------------------------------------
End of Stochastic function

Above are the defines and variables...  
I am seeking the same thing for zig and zag:

You have defined the inputs and variables for zig and the result to
the user looks like this:   zig(Close, 10 ) 

what are the inputs and variables that make the body of the zig
function or the body of the zig function, either that way or afl would
be great...

The example you gave me uses the zig function, i want the zig and zag
function itself please...

I need to get into the guts of the zig zag as I want to make changes
to it and this is the only code I could find for doing a zigzag but i
have no clu how to make this work in ami...

So in a word I really want the guts of the function you are using in
ami as shown in the stoc example or below...

Indicators::ZigZag;

# This file is distributed under the terms of the General Public
License
# version 2 or (at your option) any later version.

use strict;
use vars qw(@ISA @NAMES @DEFAULT_ARGS);

use GT::Indicators;

@ISA = qw(GT::Indicators);
@NAMES = ("ZigZag[#*]");
@DEFAULT_ARGS = (10, "{I:Prices CLOSE}");

=head1 NAME

GT::Indicators::ZigZag

=head1 DESCRIPTION 

The Zig Zag indicator filters out changes in an underlying plot (e.g.,
a security's price or another indicator) that are less than a
specified amount. The Zig Zag indicator only shows significant
changes.

=head2 Parameters

=over 

=item Percentage change (10%)

The first argument is the percentage change required to yield a line
that only reverses after a change from high to low of 10% or greater.

=back

=head2 Creation

 GT::Indicators::ZigZag->new()
 GT::Indicators::ZigZag->new([5])

If you need an 8 % ZigZag indicator of the opening prices you can
write
one of those lines :

 GT::Indicators::SMA->new([8], "OPEN", $GET_OPEN)
 GT::Indicators::SMA->new([8, "OPEN"])

A ZigZag indicator with a 20 % threshold of the Volume could be
created with :

 GT::Indicators::ZigZag->new([20, "{I:Volume}"])

=cut

sub initialize {
    my ($self) = @_;
}

sub calculate {
    my ($self, $calc, $i) = @_;
    my $percentage = $self->{'args'}->get_arg_values($calc, $i, 1);
    my $name = $self->get_name;

    return if (! defined($percentage));

    $self->remove_volatile_dependencies();
    $self->add_volatile_arg_dependency(2, $percentage);
    return if (! $self->check_dependencies($calc, $i));

    my $previous_peak = 0;
    my $zigzag = 0;
    my $date = 0;
    my $sign = 0;

    for (my $n = 0; $n <= $i; $n++) {
	
	if ($self->{'args'}->get_arg_values($calc, $n, 2) >= $previous_peak
* (1 + $percentage / 100)) {
	    if ($sign eq -1) {
		$calc->indicators()->set($name, $date, $previous_peak);
	    }
	    $date = $n;
	    $sign = 1;
	}
	if ($self->{'args'}->get_arg_values($calc, $n, 2) <= $previous_peak
* (1 - $percentage / 100)) {
	    if ($sign eq 1) {
		$calc->indicators()->set($name, $date, $previous_peak);
	    }
	    $date = $n;
	    $sign = -1;
	}
	if (($sign eq 1) and ($self->{'args'}->get_arg_values($calc, $n, 2)
> $previous_peak)) {
	    $previous_peak = $self->{'args'}->get_arg_values($calc, $n, 2);
	    $date = $n;
	}
	if (($sign eq -1) and ($self->{'args'}->get_arg_values($calc, $n, 2)
< $previous_peak)) {
	    $previous_peak = $self->{'args'}->get_arg_values($calc, $n, 2);
	    $date = $n;
	}
    }
    $calc->indicators()->set($name, $i, $previous_peak);
}

sub calculate_interval {
    my ($self, $calc, $first, $last) = @_;

    $self->calculate($calc, $last);
}

1;


thanks again
JJ




>Check, for example, for the n=1 last quotations, with
>
>per=3;
>P=Cum(PeakBars(H,per)==0);
>T=Cum(TroughBars(L,per)==0);
>Filter=1;
>AddColumn(P,"# of Peaks",1.0);
>AddColumn(T,"# of Troughs",1.0);
>AddTextColumn(WriteIf(Column0!=Column1,"*","")," * ");
>
>Stocks with the same # for Peaks and Troughs are the exceptions, not 
>the rule.
>Dimitris
>--- In amibroker@xxxxxxxxxxxxxxx, "DIMITRIS TSOKAKIS" <TSOKAKIS@xxxx> 
>wrote:
>> 
>> --- In amibroker@xxxxxxxxxxxxxxx, kaveman perth <kavemanperth@xxxx> 
>> wrote:
>> 
>> > zig zag links togeher the Peak(H,x) and Trough(L,x) points
>> 
>> kaveman,
>> Which zig does this job ?
>> The zig(C,x), the zig(H,x) or the zig(L,x) ?
>> Noone of these lines links the Peak(H,x) and Trough(L,x) points.
>> I didnīt see your point...
>> Note also that more than one troughs may exist between two 
>successive 
>> peaks. It is not that simple...
>> Dimitris
>> > On Tue, 09 Nov 2004 21:00:00 -0800, stockjunkie@xxxx
>> > <stockjunkie@xxxx> wrote:
>> > > 
>> > > Thanks to everyone for your comments and efforts...
>> > > 
>> > > I must not be using the correct vernacular here to properly 
>> describe
>> > > what I am asking for...
>> > > 
>> > > As an example if i choose stocd() there is code that is linked 
>to 
>> and
>> > > defines this function something like HH+LL/HH-LL  etc etc
>> > > 
>> > > Should I be asking for the code associated with the zigzag 
>> function
>> > > maybe?
>> > > 
>> > > I am looking for the code that defines and is linked to the 
>zigzag
>> > > function as shown in the example above...
>> > > 
>> > > JJ
>> > > 
>> > > 
>> > > Check AmiBroker web page at:
>> > > http://www.amibroker.com/
>> > > 
>> > > Check group FAQ at: 
>> http://groups.yahoo.com/group/amibroker/files/groupfaq.html
>> > > Yahoo! Groups Links
>> > > 
>> > > 
>> > > 
>> > > 
>> > > 
>> > 
>> > 
>> > -- 
>> > Cheers
>> > Graham
>> > http://e-wire.net.au/~eb_kavan/
>
>
>
>
>
>
>Check AmiBroker web page at:
>http://www.amibroker.com/
>
>Check group FAQ at: http://groups.yahoo.com/group/amibroker/files/groupfaq.html 
>Yahoo! Groups Links
>
>
>
> 
>
>



------------------------ Yahoo! Groups Sponsor --------------------~--> 
Make a clean sweep of pop-up ads. Yahoo! Companion Toolbar.
Now with Pop-Up Blocker. Get it for free!
http://us.click.yahoo.com/L5YrjA/eSIIAA/yQLSAA/GHeqlB/TM
--------------------------------------------------------------------~-> 

Check AmiBroker web page at:
http://www.amibroker.com/

Check group FAQ at: http://groups.yahoo.com/group/amibroker/files/groupfaq.html 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/amibroker/

<*> To unsubscribe from this group, send an email to:
    amibroker-unsubscribe@xxxxxxxxxxxxxxx

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/