PureBytes Links
Trading Reference Links
|
Now with dynamic last leg.
jose '-)
============
Cycle Length
============
---8<--------------------------------
{ Price peak/trough cycle length v4.0 }
{ Warning: last peak/trough is dynamic!}
{ Plot in own window below price chart }
{ ©Copyright 2004 Jose Silva }
{ http://users.bigpond.com/prominex/pegasus.htm }
{ 6/4/2004 ASX 1152 active stocks exploration,
3.25% ZigZag cycle lengths, mean price cycle:
3.7 days Long;
4.5 days Short;
8.2 trade days total.}
zzper:=Input("ZigZag reversal %",.001,100,3.25);
pds:=Input("avg StdDev periods",2,2520,7);
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);
cycle:=CycleUp+-CycleDw;
lastLeg:=If(ValueWhen(1,pk OR tr,cycle)<0,
lastleg,-lastleg)*lastBar;
cycle:=cycle+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
---8<--------------------------------
--- In Metastockusers@xxxxxxxxxxxxxxx, "Jose" <josesilva22@xxxx>
wrote:
>
> An example of one of the few valid uses for the ZigZag function:
>
> ====================
> Cycle Length average
> ====================
> ---8<--------------------------------
>
> { Plots average of price ZigZag cycle length }
> { ©Copyright 2004 Jose Silva }
> { http://users.bigpond.com/prominex/pegasus.htm }
>
> { Stats for ASX All Ords (475) stocks,
> 27/2/2004, 5% ZigZag cycle lengths:
> mean: 12 trade days;
> avg: 14 trade days.}
>
> pr:=Input("ZigZag reversal %",0,100,5);
> plot:=Input("plot: [1] Cycle, [2] Cycle Avg, [3] ZigZag",1,3,2);
> adv:=Input("adv plot 1 bar to match cycles? [1]Yes [0]No",0,1,0);
>
> x:=Zig(C,pr,%);
> y:=Ref(x,-1)>x AND Ref(x,-1)>Ref(x,-2);
> z:=Ref(x,-1)<x AND Ref(x,-1)<Ref(x,-2);
> PkTr:=y OR z;
> CycleLen:=PkTr*(Ref(BarsSince(PkTr),-1)+1);
> CycleCount:=Cum(PkTr)-1;
> CycleCount:=If(CycleCount=0,.000001,CycleCount);
> CycleLenAvg:=Cum(CycleLen)/CycleCount;
> plot:=If(plot=1,Ref(CycleLen,adv),
> If(plot=2,Ref(CycleLenAvg,adv),x));
>
> plot
>
> ---8<--------------------------------
>
>
> jose '-)
------------------------ Yahoo! Groups Sponsor ---------------------~-->
Buy Ink Cartridges or Refill Kits for your HP, Epson, Canon or Lexmark
Printer at MyInks.com. Free s/h on orders $50 or more to the US & Canada.
http://www.c1tracking.com/l.asp?cid=5511
http://us.click.yahoo.com/mOAaAA/3exGAA/qnsNAA/zMEolB/TM
---------------------------------------------------------------------~->
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/Metastockusers/
<*> To unsubscribe from this group, send an email to:
Metastockusers-unsubscribe@xxxxxxxxxxxxxxx
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/
|