Check with Elder's group
http://finance. groups.yahoo. com/group/ CIMTR/
--- In equismetastock@ yahoogroups. com, Bob Waits <bobwaits2@x ..> wrote:
>
>
>
> I came across this code by Jose Silve on a forum. Any idea on what's the best way to use this indicator?
> Thanks.----- 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 }{ josesilva22@ ... }
> 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 L<Ref(L,-1);
>
> DwSideDiff:= If(DwSidePen, Ref(L,-1) -L,0);
>
> DwPenAvg:=Sum( DwSideDiff, bkpds)
>
> /(Sum(DwSidePen, bkpds)+.000001) ;
>
> StLong:=Ref( L-DwPenAvg* coefficient, -1);
>
> StopLong:=If( C<PREV,StLong, Max(StLong, PREV));
>
>
>
> UpSidePen:=Mov( C,pds,E)< Ref(Mov(C, pds,E),-1)
>
> AND H>Ref(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))
>