Cycle Indicator --------------- MetaStock -> Tools -> Indicator Builder -> New Copy and paste formula below. ============ Cycle Length ============ ---8<-------------------------------- { Price peak/trough cycle length v4.0 } { Warning: last peak/trough is dynamic!} { Plot in own window below price chart } { 6/4/2004 ASX 1152 active stocks exploration, 3.25% ZigZag cycle lengths, mean price cycles: 3.7 trade days for positive price cycles; 4.5 trade days for negative price cycles; 8.2 trade days complete price cycles.} { ©Copyright 2004 Jose Silva } { http://www.metastocktools.com } 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); 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 ---8<-------------------------------- Market Cycle Explorations ------------------------- MetaStock -> Tools -> The Explorer -> New Copy and paste formulae below. ==================== Zig Zag price cycles ==================== ---8<--------------------------- *Input today's data date in filter section!* Last (dynamic) and previous (static) cycles, based on default values in indicator "ZigZag Cycle Length". 6/4/2004 ASX 1152 active stocks exploration, 3.25% ZigZag cycle lengths, last price cycles: 4 trade days for positive price cycles; 5 trade days for negative price cycles; 9 trade days complete price cycles. ©Copyright 2004 Jose Silva http://www.metastocktools.com ------------------ Column A: + cycle { last positive dynamic cycle } x:=Fml("ZigZag Cycle Length"); If(x>0,x,0) ------------------ Column B: - cycle { last negative dynamic cycle } x:=Fml("ZigZag Cycle Length"); If(x<0,x,0) ------------------ Column C: AbsCycle { absolute last cycle } Abs(Fml("ZigZag Cycle Length")) ------------------ Column D: + prev { previous complete (static) positive cycle } x:=FmlVar("ZigZag Cycle Length","CYCLEUP"); ValueWhen(1,x<>0,x) ------------------ Column E: - prev { previous complete (static) negative cycle } x:=FmlVar("ZigZag Cycle Length","CYCLEDW"); -ValueWhen(1,x<>0,x) ------------------ Column F: TotalPrv { total last complete (static) full cycle } x:=FmlVar("ZigZag Cycle Length","CYCLEUP"); y:=FmlVar("ZigZag Cycle Length","CYCLEDW"); ValueWhen(1,x<>0,x)+ValueWhen(1,y<>0,y) ------------------ Filter: { Today's data date, user-input section } day:= 6; { current day of month (1~31) } mth:= 4; { current month (1~12) } yr:= 2004; { current year, eg 2004 } { *********************************** } DayOfMonth()=day AND Month()=mth AND Year()=yr AND V>0 ---8<--------------------------- ============================ Zig Zag price cycle averages ============================ ---8<--------------------------- *Input today's data date in filter section!* Historical Average & StdDev of static cycles, based on default values in indicator "ZigZag Cycle Length". 6/4/2004 ASX 1152 active stocks exploration, 3.25% ZigZag cycle lengths, mean price cycles: 3.7 trade days for positive price cycles; 4.5 trade days for negative price cycles; 8.2 trade days complete price cycles. ©Copyright 2004 Jose Silva http://www.metastocktools.com ------------------ Column A: + avg { historical positive static cycle average } FmlVar("ZigZag Cycle Length","CYCLEUPAVG") ------------------ Column B: - avg { historical negative static cycle average } -FmlVar("ZigZag Cycle Length","CYCLEDWAVG") ------------------ Column C: TotalAvg { historical full static cycle average } FmlVar("ZigZag Cycle Length","CYCLEUPAVG")+ Abs(FmlVar("ZigZag Cycle Length","CYCLEDWAVG")) ------------------ Column D: + StdDev { Standard Deviation of positive static cycles} FmlVar("ZigZag Cycle Length", "CYCLEUPSTDDEVAVG") ------------------ Column E: - StdDev { Standard Deviation of nagative static cycles} -FmlVar("ZigZag Cycle Length", "CYCLEDWSTDDEVAVG") ------------------ Column F: TotStdDv { Standard Deviation of full static cycles } (FmlVar("ZigZag Cycle Length", "CYCLEUPSTDDEVAVG") +FmlVar("ZigZag Cycle Length", "CYCLEDWSTDDEVAVG"))/2 ------------------ Filter: { Today's data date, user-input section } day:= 6; { current day of month (1~31) } mth:= 4; { current month (1~12) } yr:= 2004; { current year, eg 2004 } { *********************************** } DayOfMonth()=day AND Month()=mth AND Year()=yr AND V>0 ---8<--------------------------- http://www.metastocktools.com