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

Trade Equity Long and Exp



PureBytes Links

Trading Reference Links

Here is a modified version of Trade Binary and Trade Equity. The short side components have been
removed and the two indicators merged into one Trade Equity Long indicator. This test version has
preset entry and exit code instead of external formulas so it should drop onto any chart without a
problem. A revised exploration is also included to give multi-stock testing capability. The
exploration executes much faster than with the original seperate Trade Binary and Trade Equity
indicators.

Roy

  {Trade Equity Long}
OptionE:=Input("Enter: 1=O 2=C 3=H 4=L 5=Stop",1,5,2);
OptionX:=Input( "Exit: 1=O 2=C 3=H 4=L 5=Stop",1,5,2);
EntryDelay:=Input("Trade entry delay",0,3,0);
CloseDelay:=Input("Trade exit delay ",0,3,0);
Capital:=Input("Position size",500,50000,5000);
Costs:=Input("Brokerage",0,100,25);
EnterLong:=Cross(Mov(C,9,E),Mov(C,13,E));
CloseLong:=Cross(Mov(C,13,E),Mov(C,9,E));
LongEntryStop:=0;
LongCloseStop:=0;
  {** Do not change any code below this line **}
LongEntryStop:=If(OptionE=5,LongEntryStop,0);
LongCloseStop:=If(OptionX=5,LongCloseStop,0);
LongEntryPrice:=If(OptionE=5 AND LongEntryStop
  >0,Max(O,LongEntryStop),If(OptionE=1,O,
  If(OptionE=3,H,If(OptionE=4,L,C))));
LongExitPrice:=If(OptionX=5 AND LongCloseStop
  >0,Min(O,LongCloseStop),If(OptionX=1,O,
  If(OptionX=3,H,If(OptionX=4,L,C))));
EnterLong:=If(OptionE=5,If(LongEntryStop>
  0,1,0),Ref(EnterLong,-EntryDelay));
CloseLong:=If(OptionX=5,If(LongCloseStop>
  0,1,0),Ref(CloseLong,-CloseDelay));
Init:=Cum(EnterLong<>2 AND CloseLong<>2)=1;
Trade:=If(BarsSince(EnterLong OR Init)>=
  BarsSince(CloseLong OR Init),0,2);
LongEntry:=Alert(Trade<1,2) AND Trade >=1;
LongExit:=Alert(Trade>=1,2) AND Trade <1;
LastBar:=(Trade<>0 OR Alert(Trade<>0,2)) AND
  LastValue(Cum(1)-0)=Cum(1);
LongEntryPrice:=ValueWhen(1,Init OR LongEntry,
  LongEntryPrice);
Gain:=If(LongExit OR (LastBar AND Trade>=1),
  (Capital-Costs)* (LongExitPrice/LongEntryPrice)-Capital-Costs,0);
Equity:=Cum(Gain) +
 If(Trade>=1 AND LastBar=0,(Capital-Costs)*
  (LongExitPrice/LongEntryPrice),Capital);
Equity;

 {Exploration - Trade Equity Long}
ColumnA: $ Profit
  {Net profit}
Capital:=FmlVar("Trade Equity Long","Capital");
Fml("Trade Equity") - Capital
ColumnB: $ Win
  {Amount of winning trades}
Gain:=FmlVar("Trade Equity Long","Gain");
Cum(If(Gain>0,Gain,0));
ColumnC: $ Loss
  {Amount of losing trades}
Gain:=FmlVar("Trade Equity Long","Gain");
Cum(If(Gain<=0,Gain,0));
ColumnD: LongWins
  {Number of winning long trades}
Exit:=FmlVar("Trade Equity Long","LongExit");
Gain:=FmlVar("Trade Equity Long","Gain");
Cum(If(Exit AND Gain>0,1,0));
ColumnE: LongLoss
  {Number of losing long trades}
Exit:=FmlVar("Trade Equity Long","LongExit");
Gain:=FmlVar("Trade Equity Long","Gain");
Cum(If(Exit AND Gain<=0,1,0));
ColumnF: # BarsIn
  {Total bars in all trades}
Trade:=FmlVar("Trade Equity Long","Trade");
Cum(If(Alert(Trade<>0,2),1,0));
Filter Enabled: No
Minimum bars recommended: 300