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

[EquisMetaStock Group] Re: Signal for the indicator Zig Zag



PureBytes Links

Trading Reference Links

I understand that in the Zig Zag formula we input a minimum 
percentage to calculate the zig & the zag.  Given the minimum %, how 
can Jose's Zig Zag formula below be modified to include an output 
that tells us the percentage rise and fall of the prices at the zig 
zag points? The percentages would be triggered by Jose's buy(+1)/sell
(-1). I think this uses the valuewhen function, but I am have 
trouble with it. When calculating the rate of return ((ending value -
 beginning value)/beg value) it would use the high price at peaks 
(+1) and the low at valleys(-1).  The output would look like Jose's
"Price peak/trough cycle length v4.0"

zzper:=20;
pds:=2;
plot:=Input("[1]Cycles, [2]Cycle Avg, [3]Avg StdDev, [4]
ZigZag",1,4,1);

pk:=PeakBars(1,C,zzper)=0;
tr:=TroughBars(1,C,zzper)=0;
lastBar:=Cum(1)=LastValue(Cum(1));
lastLeg:=lastBar*LastValue(BarsSince(pk OR tr));

CycleUp:=pk*BarsSince(tr);
CycleUpAvg:=
 Cum(CycleUp)/(Cum(CycleUp>0)+.000001);
CycleUpStdDev:=Stdev(CycleUp,pds);
CycleUpStdDevAvg:=Cum(CycleUpStdDev)
 /(Cum(CycleUpStdDev>0)+.000001);

CycleDw:=tr*BarsSince(pk);
CycleDwAvg:=
 Cum(CycleDw)/(Cum(CycleDw>0)+.000001);
CycleDwStdDev:=Stdev(CycleDw,pds);
CycleDwStdDevAvg:=Cum(CycleDwStdDev)
 /(Cum(CycleDwStdDev>0)+.000001);

statCycle:=CycleUp-CycleDw;
lastLeg:=If(ValueWhen(1,pk OR tr,statCycle)<0,
 lastleg,-lastleg)*lastBar;
cycle:=statCycle+lastLeg;
zz:=Zig(cycle,zzper,%);

plotUp:=If(plot=1,0,
 If(plot=2,CycleUpAvg,
 If(plot=3,CycleUpStdDevAvg,0)));
plotDw:=If(plot=1,cycle,
 If(plot=2,-CycleDwAvg,
 If(plot=3,-CycleDwStdDevAvg,zz)));

plotUp;plotDw

I would like to use this to look at the historical cycles: rises & 
drawdowns of an investment.  Jose's formulas on zig zag length have 
been very helpful in this analysis.  For me anyway, the combination 
zig/zag length & % rise/fall is more meaningful than modern 
portfolio theories mean, standard deviation, beta & alpha.

Thanks for your help.
Jeff

--- In equismetastock@xxxxxxxxxxxxxxx, "cengovit" <cengovit@xxx> 
wrote:
>
> --- In equismetastock@xxxxxxxxxxxxxxx, "Jose Silva" <josesilva22@>
> wrote:
> >
> > Edson, try this indicator:
> > 
> > =================
> > ZigZag Buy & Sell
> > =================
> > ---8<-------------------------
> > 
> > { Note!
> >   ----
> >    Last leg of ZigZag is *always dynamic*,
> >    and last peak/trough signals are
> >    always plotted in hindsight. 
> > 
> > ©Copyright 2004~2006 Jose Silva.
> >  For personal use only.
> >  http://www.metastocktools.com }
> > 
> > { User inputs }
> > pr:=Input("ZigZag reversal %",.01,100,5);
> > x:=Input("use: [1]Open, [2]High, [3]Low, [4]Close, [5]
WghtCl",1,5,4);
> > plot:=Input("plot:  [1]Signals,  [2]ZigZag",1,2,1);
> > 
> > { Select data array }
> > x:=If(x=1,O,If(x=2,H,If(x=3,L,If(x=4,C,WC()))));
> > 
> > { ZigZag }
> > zz:=Zig(x,pr,%);
> > 
> > { Peak/Trough }
> > sell:=PeakBars(1,x,pr)=0;
> > buy:=TroughBars(1,x,pr)=0;
> > 
> > { Plot signals in own window, ZigZag on chart }
> > If(plot=1,buy-sell,zz)
> > 
> > ---8<-------------------------
> > 
> > 
> > jose '-)
> > http://www.metastocktools.com
> > 
> > 
> > 
> > 
> > --- In equismetastock@xxxxxxxxxxxxxxx, "Edson L F" <edsonlf@> 
> > wrote:
> > >
> > > Hi all,
> > > How to make a signal (positive=buy and negative=sell) for the
> > > indicator Zig Zag?
> > > 
> > > Thanks in advance.
> >
> 
> Hi, 
> 
> I am new to metastock (only couple of days) so, I really dont now 
how
> to write my own stuff. Can any of you guys convert this "zig-zag
> buy/sell" indicator to "Explorer" format?
> 
> Possibly search for a sell or buy signal generated with in last 2 
bars
>  or something like that?
> 
> thanks in advance....
>




 
Yahoo! Groups Links

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

<*> Your email settings:
    Individual Email | Traditional

<*> To change settings online go to:
    http://groups.yahoo.com/group/equismetastock/join
    (Yahoo! ID required)

<*> To change settings via email:
    mailto:equismetastock-digest@xxxxxxxxxxxxxxx 
    mailto:equismetastock-fullfeatured@xxxxxxxxxxxxxxx

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

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