A custom Lookback.dll is also available from the author for US$120. ExtFml( "LookBack.Days", DataArray, Calendar days) This custom MS external function works as the indicator below, but in addition it also references a fixed calendar day lookback for all chart bars (not just the last one), and accepts variable inputs. MetaStock -> Tools -> Indicator Builder -> New -> Copy and paste both formulae below. ================== Calendar day Ref() ================== ---8<--------------------------- { CalendarDay-based Ref() function v1.0 ©Copyright 2005 Jose Silva For personal use only. http://www.metastocktools.com } { User inputs } days:=Input("Calendar Days lookback",0,36500,7); x:=Input("[1]Open [2]High [3]Low [4]Close [5]WCl [6]Vol",1,6,4); plot:=Input("Calendar Lookback: [1]Price, [2]Signal",1,2,1); { Data Array } x:=If(x=1,O,If(x=2,H,If(x=3,L,If(x=5,WC(), If(x=6,V,C))))); { Calendar days counter } calendar:=Fml("Calendar Day counter"); { Calendar day CountDown } countDown:=LastValue(calendar)-calendar; { Lookback reference signal } signalZone:=countDown<=days OR Cum(1)=1; signal:=signalZone*Alert(signalZone=0,2) OR Cum(1)=1; { Reference price x calendar days ago } calRef:=If(signalZone,ValueWhen(1,signal,x),x); { Plot on price chart } If(plot=1,calRef,signal) ---8<--------------------------- ==================== Calendar Day counter ==================== ---8<--------------------------- { Day counter from 1/1/0001, Gregorian calendar } { Count is independent of any missing chart data } { ©Copyright 2003-2004 Jose Silva } { http://www.metastocktools.com } limit:=Input("count calendar days from year",1,2100,2000); LimLeap:=Frac(limit/4)=0 AND Frac(limit/100)<>0 OR Frac(limit/400)=0; NoCount:=limit*365+Int(limit/4) -Int(limit/100)+Int(limit/400)-LimLeap; 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)-NoCount; 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))))))))))); DayNr:=y+m+DayOfMonth(); DayNr ---8<--------------------------- http://www.metastocktools.com