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

RE: Multi Stop Indicator



PureBytes Links

Trading Reference Links

This looks really great if it works. I haven't tried it yet.
But what about this Metastock add-on which also looks really great.
http://www.compuvision.com.au/index.htm

Greetings and thanks
M.

-----Original Message-----
From: owner-metastock@xxxxxxxxxxxxx
[mailto:owner-metastock@xxxxxxxxxxxxx] On Behalf Of Roy Larsen
Sent: donderdag 25 oktober 2001 20:33
To: metastock@xxxxxxxxxxxxx
Subject: Re: Multi Stop Indicator


Tom

> Roy, did you ever find and correct the bug in the Multi Stop indicator

> you talked about?  Sure looks interesting!

Regrettably, no. Each time I think I have a solution I find another flaw
in the logic. It seems that using a PREV is the only way to go without
resorting to a dll. Since I have neither the MDK nor the programming
skills to use it effectively I am unable to produce the result I had
hoped for. For what it's worth here is my current PREV version. Take
care if trying to match trades and stops to the MS System Tester as this
indicator is intended for use with a fixed position size (as opposed to
compounding), as used by the enabled code of Trade Equity LE, also
included.

Just for good measure I'm also including 1 exploration to give the fixed
equity code of Trade Equity LE basic multi-stock testing capability.
Unfortunately when Trade Stop LE (with PREV) is used with Trade Equity
LE the exploration across multiple stocks is intolerably slow. If you
have a FAST computer then speed may not be such an issue.

Roy

  {Trade Stop LE}
No:=Input("Enter 1=O 2=C 3=Stop",1,3,2);
Xo:=Input("Close 1=O 2=C 3=Stop",1,3,2);
Nd:=Input("Entry Delay",0,3,0);
Xd:=Input("Close Delay",0,3,0);
Pt:=Input("Profit Target %",1,99,25)/100;
Ls:=Input("Maximum Loss % ",1,99,10)/100;
Cm:=25;                        {Trade commision}
Cp:=5000;                      {Trade capital}
N:=Fml("Your Entry");         {Entry formula}
X:=Fml("Your Exit");          {Close formula}
N:=If(No=3,N,Ref(N,-Nd));
X:=If(Xo=3,X,Ref(X,-Xd));
Np:=If(No=1,O,If(No=2,C,N));   {Entry price}
Xp:=If(Xo=1,O,If(Xo=2,C,X));   {Close price}
Pf:=(Cp*(1+Pt)+Cm)/(Cp-Cm);    {Profit factor}
Lf:=(Cp*(1-Ls)+Cm)/(Cp-Cm);    {Loss factor}
    {+Cm for exit, -Cm for entry}
Tr:=If(PREV=0,If(N>0,Np,0),
If(X>0 OR If(Xo<3,Xp,H)>=PREV*Pf OR If(Xo<3,Xp,L)<=PREV*Lf,0,PREV));
Xb:=Tr=0 AND Alert(Tr>0,2);      {Exit bar}
Ev:=ValueWhen(1,(Cum(N>-1 AND X>-1)=1) OR Tr>0,Tr);   {Entry value}
Sp:=If(Xb,If(Xo<3,If(Xp>=Ev*Pf,Xp,0),
If(O>=Ev*Pf,O,If(H>=Ev*Pf,Ev*Pf,0))),0);
Sl:=If(Xb,If(Xo<3,If(Xp<=Ev*Lf,Xp,0),
If(O<=Ev*Lf,O,If(L<=Ev*Lf,Ev*Lf,0))),0);
Tr; Tr*Pf; Tr*Lf; {Entry amt, Target, Stoploss}
If(Xb,If(Xo<3,1,If(Sp>0,Sp,If(Sl>0,Sl,X))),0);

  {Trade Equity LE}
No:=Input("Enter 1=O 2=C 3=Stop",1,3,3);
Xo:=Input("Close 1=O 2=C 3=Stop",1,3,1);
Nd:=Input("Entry Delay",0,3,0);
Xd:=Input("Close Delay",0,3,0);
Cm:=Input("Trade Commission $",0,999,25);
Cp:=Input("Trade Capital $",1000,100000,5000);
N:= 0;
Ns:=Fml("Your Entry");
X:= Fml("Your Exit"); {Or Fml("Trade Stop LE")}
Xs:=0;
  {*** Do not change code below this line ***} Ns:=If(No=3,Ns,0);
Np:=If(No=1,O,If(No=2,C,Ns)); N:=N AND Alert(N=0,2);
N:=If(Nd=0,N,Alert(N,Nd+1) AND Alert(N,Nd)=0);
N:=If(No=3 AND Np>0,1,If(No<3,N,0));
Xs:=If(Xo=3,Xs,0);
Xp:=If(Xo=3 AND Xs>0,Min(O,Xs),If(Xo=1,O,C));
X:=X AND Alert(X=0,2);
X:=If(Xd=0,X,Alert(X,Xd+1) AND Alert(X,Xd)=0); X:=If(Xo=3,If(Xp>=L AND
Xs>0,1,0),X); Xp:=If(Xo<3 AND No=3 AND X=0,C,Xp); Xp:=If(Xo=3 AND Xs>0
AND N AND X,Xs,Xp); Xp:=If(Ref(Xo=3 AND N AND X,-1),Ref(Xp,-1),Xp);
I:=Cum(N<>-1 AND X<>-1)=1; Tr:=If(BarsSince(I OR N)>= BarsSince(I OR
X),0,1); Tr:=If(N AND X AND (No=3 OR Xo=3),1,Tr); Np:=If(I AND
N=0,C,Np); En:=(Tr AND Alert(Tr=0,2)) OR I; Ex:=Tr=0 AND Alert(Tr,2);
Lb:=(Tr OR Alert(Tr,2)) AND LastValue(Cum(1)-0)=Cum(1);
Ea:=ValueWhen(1,En,If(No=3 AND N AND X,Np,Max(O,Np)));
Ea:=If(No<3,ValueWhen(1,En,Np),Ea);
En:=Tr AND Alert(Tr=0,2);
  {*** Use Cs & Pf for compound equity ***}
{Cs:=Cum(If(I,Cp,0)- If(En,Cm,0)- If(Ex,Cm,0));
Pf:=Cum(If(Alert(Tr,2) AND If(No=3,1,En=0),
(PREV+If(No=3 AND En,Cs,Ref(Cs,-1)))*
If((No=3 AND En) OR (No<3 AND En=0 AND Alert(En,2)),
(Xp-Ea)/Ea,(Xp-Ref(Xp,-1))/Ref(Xp,-1)),0));
Pf+Cs;}
  {*** Use Gn & Tl for fixed Equity ***}
Gn:=If(Ex OR Lb,(Cp-Cm)*(Xp/Ea)-Cp-Cm,0);
Tl:=Cum(Gn)+If(Tr AND Lb=0,(Cp-Cm)*(Xp/Ea),Cp)+ If(Tr AND Lb,Cm,0); Tl;

  {Trade Equity LE Exploration}
Periodicity: Daily
COLUMN FORMULAS
ColumnA: $ Profit
  {Net profit}
Cum(FmlVar("Trade Equity LE","Gn"));
ColumnB: $ Win
  {Amount of winning trades}
Gain:=FmlVar("Trade Equity LE","Gn");
Cum(If(Gain>0,Gain,0));
ColumnC: $ Loss
  {Amount of losing trades}
Gain:=FmlVar("Trade Equity LE","Gn");
Cum(If(Gain<0,Gain,0));
ColumnD: # Win
  {Number of winning long trades}
Gain:=FmlVar("Trade Equity LE","Gn");
Cum(If(Gain>0,1,0));
ColumnE: # Loss
  {Number of losing long trades}
Gain:=FmlVar("Trade Equity LE","Gn");
Cum(If(Gain<0,1,0));
ColumnF: # BarsIn
  {Total bars in all trades}
Trade:=FmlVar("Trade Equity LE","Tr"); Cum(If(Alert(Trade<>0,2),1,0));
FILTER SOURCE Filter Enabled: No Recommended minimum bars to test: 250