MetaStock -> Tools -> Indicator Builder -> New Copy and paste formulae below. ============================== Calendar Day/Week calc counter ============================== ---8<------------------------------------- {Calendar Week/Day calculator/counter v1.0 Calculates/counts future/past calendar days/weeks from current chart data date. Count is independent of any missing chart data. ©Copyright 2002~2006 Jose Silva. The grant of this license is for personal use only - no resale or repackaging allowed. All code remains the property of Jose Silva. http://www.metastocktools.com } { User inputs } Day:=Input("new Day",1,31,25); Mth:=Input("new Month",1,12,12); Yr:=Input("new Year",1800,2200,2006); plot:=Input("Count: [1]Days, [2]Weeks",1,2,1); adj:=Input("Week's start: [0]Sunday, [1]Monday",0,1,1); { Calendar counter engine } leap:=Frac(Year()/4)=0 AND Frac(Year()/100)<>0 OR Frac(Year()/400)=0; y:=Year()*365+Int(Year()/4) -Int(Year()/100)+Int(Year()/400)-730484; m:= If(Month()=2,31-leap, If(Month()=3,59, If(Month()=4,90, If(Month()=5,120, If(Month()=6,151, If(Month()=7,181, If(Month()=8,212, If(Month()=9,243, If(Month()=10,273, If(Month()=11,304, If(Month()=12,334, -leap))))))))))); toDay:=y+m+DayOfMonth(); adjx:=adj+If(toDay<1,1,2) -(Frac(Year()/100)=0 AND Frac(Year()/400)<>0); toWeek:=Int((toDay-adjx)/7)+(Year()>=2000); { Past/Future Calendar counter } leap:=Frac(Yr/4)=0 AND Frac(Yr/100)<>0 OR Frac(Yr/400)=0; y:=Yr*365+Int(Yr/4)-Int(Yr/100)+Int(Yr/400) -730484; m:= If(Mth=2,31-leap, If(Mth=3,59, If(Mth=4,90, If(Mth=5,120, If(Mth=6,151, If(Mth=7,181, If(Mth=8,212, If(Mth=9,243, If(Mth=10,273, If(Mth=11,304, If(Mth=12,334, -leap))))))))))); nuDay:=y+m+Day; adjx:=adj+If(nuDay<1,1,2) -(Frac(Yr/100)=0 AND Frac(Yr/400)<>0); nuWeek:=Int((nuDay-adjx)/7)+(Yr>=2000); { Day/Week count } Day:=nuDay-toDay; Week:=nuWeek-toWeek; { Plot in own window } If(plot=1,Day,Week) ---8<------------------------------------- http://www.metastocktools.com