---------------------------------------------------- Also available for US$80: Intraday/EOD combined timeframe detector ---------------------------------------- * Displays current intraday chart timeframe in minutes: Detects any standard or custom intraday timeframe from tick up to and including 60min charts, and up to 1440min charts in MetaStock v10.0+. * Detects Daily/Weekly/Monthly/Quarterly/Yearly charts. * Can be referenced by any MetaStock process. ---------------------------------------------------- MetaStock -> Tools -> Indicator Builder -> New Copy and paste all formulae below. ==================== Periodicity detector ==================== ---8<--------------------------------- {EOD chart periodicity detector - v2.0 ©Copyright 2003-2010 Jose Silva http://www.metastocktools.com } {Message} dummy:=Input("Charts detected: [1] Daily, [2] Weekly, ",0,0,0); dummy:=Input("[3] Monthly, [4] Quarterly, [5] Yearly",0,0,0); {Calendar counter engine} y:=Year()-(Month()<3); leap:=Int(y/4)-Int(y/100)+Int(y/400); mth:=Int((2+153*(Month()-3+12*(Month()<3)))/5); dayNr:=DayOfMonth()+mth+y*365+leap-730425; adj:=1+If(DayNr<1,1,2); {Wk/Mth/Qtr/Yr count} Wk:=Int((DayNr-adj)/7)+(Year()>=2000); {FortnightCount:=Int((Wk+1)/2);} m:=Month(); Mth:=Cum(m<>ValueWhen(2,1,m)); q:=(m<4)+(m>3 AND m<7)*2 +(m>6 AND m<10)*3+(m>9)*4; Qtr:=Cum(q<>ValueWhen(2,1,q)); Yr:=Cum(Year()<>ValueWhen(2,1,Year())); {Chart periodicity detection} chart:=If(LastValue(Cum(Wk=ValueWhen(2,1,Wk)))=0,2,1); chart:=If(LastValue(Cum(Mth=ValueWhen(2,1,Mth)))=0,3,chart); chart:=If(LastValue(Cum(Qtr=ValueWhen(2,1,Qtr)))=0,4,chart); chart:=If(LastValue(Cum(Yr=ValueWhen(2,1,Yr)))=0,5,chart); {Plot in own narrow window} chart ---8<--------------------------------- ================================ Periodicity detector app example ================================ ---8<--------------------------------- {Chart periodicity detector application example. Automatically adjusts EMA to chart periodicity. References indicator "Calendar Week counter". ©Copyright 2003-2006 Jose Silva http://www.metastocktools.com } Wk:=Fml("Calendar Week counter"); {Frt:=Int((Wk+1)/2);} m:=Month(); Mth:=Cum(m<>ValueWhen(2,1,m)); q:=If(m=1 OR m=2 OR m=3,1, If(m=4 OR m=5 OR m=6,2, If(m=7 OR m=8 OR m=9,3,4))); Qtr:=Cum(q<>ValueWhen(2,1,q)); Yr:=Cum(Year()<>ValueWhen(2,1,Year())); chart:=If(LastValue(Cum(Wk=ValueWhen(2,1,Wk)))=0,2,1); chart:=If(LastValue(Cum(Mth=ValueWhen(2,1,Mth)))=0,3,chart); chart:=If(LastValue(Cum(Qtr=ValueWhen(2,1,Qtr)))=0,4,chart); chart:=If(LastValue(Cum(Yr=ValueWhen(2,1,Yr)))=0,5,chart); pds:=Input("daily EMA periods",1,25200,126); x:=Input("use Open=1 High=2 Low=3 Close=4 Volume=5 P=6",1,6,6); shift:=1+Input("EMA vertical shift %", -100,100,0)/100; plot:=Input("EMA=1, Crossover signals=2",1,2,1); x:=If(x=1,O,If(x=2,H,If(x=3,L,If(x=5,V,If(x=6,P,C))))); pds:=If(chart=1,pds,If(chart=2,pds/5, If(chart=3,pds/21,If(chart=4,pds/63,pds/252)))); pds:=If(pds<1,1,pds); pds:=If(pds>Cum(IsDefined(x)), Cum(IsDefined(x)),pds); Ema:=x*2/(pds+1)+PREV*(1-2/(pds+1)); Ema:=Ema*shift; signals:=Cross(x,Ema)-Cross(Ema,x); If(plot=2,signals,Ema) ---8<--------------------------------- http://www.metastocktools.com