MetaStock -> Tools -> Indicator Builder -> New Copy and paste formula below. ================================ Trailing Stop - Elder's SafeZone ================================ ---8<--------------------------- { Dr Alexander Elder's SafeZone trailing stop v2 } { Triggers: Long (+1) & Short (-1) signals at crossover of user-defined trailing stops } { ©Copyright 2003 Jose Silva } { http://www.metastocktools.com } coefficient:=Input("SafeZone coefficient", 0,10,2.5); bkpds:=Input("Lookback periods",1,252,10); pds:=Input("Trend EMA periods",2,252,21); adv:=Input("plot: today's SafeZone=0, tomorrow's stop=1",0,1,0); plot:=Input("plot: trailing stop=1, Long+Short=2, signals=3",1,3,1); delay:=Input("Entry and Exit signal delay", 0,5,0); DwSidePen:=Mov(C,pds,E)>Ref(Mov(C,pds,E),-1) AND LRef(H,-1); UpSideDiff:=If(UpSidePen,H-Ref(H,-1),0); UpPenAvg:=Sum(UpSideDiff,bkpds) /(Sum(UpSidePen,bkpds)+.000001); StShort:=Ref(H+UpPenAvg*coefficient,-1); StopShort:=If(C>PREV,StShort,Min(StShort,PREV)); In:=Cross(C,Ref(StopShort,-1)); Out:=Cross(Ref(StopLong,-1),C); flag:=BarsSince(Cum(In+Out>-1)=1 OR In) < BarsSince(Cum(In+Out>-1)=1 OR Out) +(Cum(In)=1); signals:=Ref((Cum(In)=1 AND Alert((Cum(In)=1)=0,2) OR flag AND Alert(flag=0,2)) -(flag=0 AND Alert(flag,2)),-delay); If(plot=1,Ref(If(flag=1,stopLong,stopShort), -1+adv),If(plot=2,Ref(stopLong,-1+adv),0)); If(plot=1,Ref(If(flag=1,stopLong,stopShort), -1+adv),If(plot=2,Ref(stopShort,-1+adv), signals)) ---8<--------------------------- http://www.metastocktools.com