[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: [EquisMetaStock Group] Metastock Fixed Trailing Stop Loss



PureBytes Links

Trading Reference Links




<FONT face=Arial color=#0000ff 
size=2>Roy,
<FONT face=Arial color=#0000ff 
size=2> 
Thanks 
for sharing this code for multi-exits using a latch. As you mentioned, the 
example below is more complex, so I guess I have something to try and get my 
head around for the next few days!
 
<FONT face="Kunstler Script" color=#008000 
size=5>Regards,
<FONT face="Kunstler Script" color=#008000 
size=5> 
Gordon 
Sutherland

  
  <FONT 
  face=Tahoma size=2>-----Original Message-----From: Roy Larsen 
  [mailto:rlarsen@xxxxxxxxxxxxxx] Sent: Monday, 11 August 2003 10:49 
  a.m.To: equismetastock@xxxxxxxxxxxxxxxSubject: Re: 
  [EquisMetaStock Group] Metastock Fixed Trailing Stop 
  LossGordonHere's an example on the more 
  complex side. This code is intended as acompanion for 'Trade Equity' so 
  don't be concerned if it doesn't make muchsense. It's a little dated and 
  probably not bug-free, but if you look at thefirst 'Tr' variable you'll 
  see how a range of possible exits are tested bythe latch. The second 'Tr' 
  variable to cover intraday trade situations whenusing EOD data (entry and 
  exit on the same bar).Roy  {Trade Stop LE Trail} {V2.7 
  long equal}No:=Input("Enter 1=O 2=C 3=H 4=L 5=Stop",1,5,2);Xo:=Input(" 
  Exit 1=O 2=C 3=H 4=L 5=Stop",1,5,2);Nd:=Input("Entry 
  Delay",0,3,0);Xd:=Input(" Exit Delay",0,3,0);Cm:=Input("Entry 
  Commission $",0,99,50);Cx:=Input(" Exit Commission 
  $",0,99,50);Cp:=10000; {* trade capital *}Ls:=12.5 {stop loss % } 
  /100;Xc:=2; {timing, 1=C/O+ 2=C/C 3=Stop/C 4=Stop}Am:=3; 
  {multiplier}Ap:=3; {trail from price, 1=MP 2=C 3=H 
  4=L}N:=Cross(Mov(C,15,E),Mov(C,25,E));Ns:=0;X:= 
  0;Xs:=0;  {end of user 
  area}Ap:=If(Ap=2,C,If(Ap=3,H,If(Ap=4,L,MP())));Am:=Ap-ATR(10)*Am; 
  Ap:=Ref(Am,-1);N:=N AND Alert(N=0,2);X:=X AND 
  Alert(X=0,2);N:=If(Nd=0,N,Alert(N,Nd+1) AND 
  Alert(N,Nd)=0);N:=If(N>0,If(No=1,O,If(No=3,H,If(No=4,L,C))),0);N:=If(No=5,If(Ns>0,Max(L,Ns),0),N);X:=If(Xd=0,X,Alert(X,Xd+1) 
  AND 
  Alert(X,Xd)=0);X:=If(X>0,If(Xo=1,O,If(Xo=3,H,If(Xo=4,L,C))),0);X:=If(Xs>0 
  AND 
  Xo=5,Max(L,Xs),X);Lf:=Min(1,(Cp*(1-Ls)+Cx)/(Cp-Cm));Tr:=If(PREV=0,If(N>0 
  AND X=0 AND(No=2 OR If(Xc<3,C,L)>Max(Lf*N,Ap)),N,0), If(X>0 
  ORIf(Xc<3,C,L)<=HighestSince(1,PREV=0,Ap) 
  OR(If(Xc<3,C,L)<=Lf*PREV AND 
  Ls<>.99),0,PREV));Tr:=If(Alert(Tr>0,2)=0 AND N>0 
  AND(((If(Xc<3,C,L)<=Max(Lf*N,Ap))AND No<>2) OR (X>0 AND 
  Nd+Xd<1 AND No<>2 ANDXo>1 AND (Max(No,Xo)>4 OR 
  No<>Xo))),-N,Tr);Xb:=(Tr=0 AND Alert(Tr>0,2)) OR (Tr<0 AND 
  Alert(Tr=0,2));Cx:=ValueWhen(1,Cum((N+Ns+X+Xs+Ap)>-1)=1 OR 
  Tr<>0,Abs(Tr));Cm:=Max(HighestSince(1,Alert(Tr,2)=0,Ap),Cx*Lf);Cm:=If(Xb,If(Xc<3 
  AND C<=Cm,C,If(Xc>2 AND 
  L<=Cm,Cm,0)),0);Cm:=If(Cm>0,If(Cm>=.5,PREC(Cm,2),If(Cm<.1,PREC(Cm,3),PREC(Cm*2,2)/2)),0);Cm:=If(Xc=4 
  AND Cm>0,Max(L,Min(If(Tr<0,H,O),Cm)),Cm);Cm:=If((Xc=2 OR Xc=3) AND 
  Cm>0,C,If(Xc=1 AND Xo<5,Ref(Cm,-1),Cm));Cm:=If(Xc=1 AND Cm>0 AND 
  Xo<5,O,Cm);Cx*Alert(Tr<>0,2); 
  Cx*Lf*Alert(Tr<>0,2);HighestSince(1,Alert(Tr<>0,2)=0,Am)*Alert(Tr<>0,2);If(Cm>0,Cm,If(Xs>0 
  AND Xo=5,X,0));To 
  unsubscribe from this group, send an email 
  to:equismetastock-unsubscribe@xxxxxxxxxxxxxxxYour 
  use of Yahoo! Groups is subject to the <A 
  href="">Yahoo! Terms of Service. 







Yahoo! Groups Sponsor


  ADVERTISEMENT 









To unsubscribe from this group, send an email to:
equismetastock-unsubscribe@xxxxxxxxxxxxxxx





Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.