¿Como configurar The Explorer de Metastock para el Alexander Elder's SafeZone?
Queria configurar el The Explorer de Metastock para que me indique acciones segun el codigo de Alexander Elder's SafeZone que transcribo a continuacion:
================================
Trailing Stop - Elder's SafeZone
================================
---8<------------------------------------------
{Dr Alexander Elder's SafeZone trailing stop v3
SafeZone types:
[1] Uses upside/downside penetration days as
suggested by Dr Elder in his book;
[2] Uses up/down days (instead of
upside/downside penetration days)
to match book's incorrect companion
spreadsheet.
Triggers: Long (+1) & Short (-1) signals at
crossover of user-defined trailing stops.
ŠCopyright 2003-2007 Jose Silva
For personal use only.
Http://www.metastocktools.com }
{ User inputs }
coefficient:=Input("SafeZone coefficient",
0,10,2.5);
bkpds:=Input("Lookback periods",1,260,10);
pds:=Input("Trend EMA periods",2,260,21);
adv:=Input("plot: [1]Today's SafeZone, [2]Tomorrow's stop",1,2,1)-1;
type:=Input("SafeZone type: [1]Book, [2]Spreadsheet",1,2,1);
plot:=Input("SafeZone: [1]Stop, [2]Long+Short, [3]Signals",1,3,1);
{ Downside penetrations }
DwSidePen:=
If(type=1,Mov(C,pds,E)>Ref(Mov(C,pds,E),-1),1)
AND L<Ref(L,-1);
DwSideDiff:=If(DwSidePen,Ref(L,-1)-L,0);
DwPenAvg:=Sum(DwSideDiff,bkpds)
/Max(Sum(DwSidePen,bkpds),.000001);
StLong:=Ref(L-DwPenAvg*coefficient,-1);
StopLong:=If(C<PREV,StLong,Max(StLong,PREV));
{ Upside penetrations }
UpSidePen:=
If(type=1,Mov(C,pds,E)<Ref(Mov(C,pds,E),-1),1)
AND H>Ref(H,-1);
UpSideDiff:=If(UpSidePen,H-Ref(H,-1),0);
UpPenAvg:=Sum(UpSideDiff,bkpds)
/Max(Sum(UpSidePen,bkpds),.000001);
StShort:=Ref(H+UpPenAvg*coefficient,-1);
StopShort:=If(C>PREV,StShort,Min(StShort,PREV));
{ Stop signals }
entry:=Cross(C,Ref(StopShort,-1));
exit:=Cross(Ref(StopLong,-1),C);
{ Clean signals }
Init:=Cum(IsDefined(entry+exit))=1;
bin:=ValueWhen(1,entry-exit<>0 OR Init,
entry-exit);
entry:=bin=1 AND (Alert(bin<>1,2) OR Init);
exit:=bin=-1 AND (Alert(bin<>-1,2) OR Init);
{ Plot on price chart }
If(plot=1,Ref(If(bin=1,stopLong,stopShort),
-1+adv),If(plot=2,Ref(stopLong,-1+adv),0));
If(plot=1,Ref(If(bin=1,stopLong,stopShort),
-1+adv),If(plot=2,Ref(stopShort,-1+adv),
entry-exit))
---8<------------------------------------------