PDA

View Full Version : Missing Trades


Pat
27th March 2006, 06:24 AM
I am currently testing a system and when I compare the trades generated from using the TradeSim exploration with the same code excluding the TradeSim formula's and including the TradeSim formula's as an indicator I get a different results.

I'm sure I'm doing something basic that is incorrect, but can't seem to see it. Could someone please point out what I'm doing wrong.

Both formulas below are indicators which show a 1 for an entry and a 2 for an exit.

Missed trades in BOQ- 27/2/2006; BLD- 22/2/2006; AUN 10/2/2006 & 21/2/2006

Example code excluding TradeSim formula's in an indicator to show Entry signals only:

{=== LONG TRADES ===}

LE := Ref(C+1.0*ATR(50),-1);

LongEntryTrigger :=
{T} Ref(Cross(C,Ref(HHV(H,3),-1)) AND
{1} C>=0.5 AND C <= 20.0 AND
{2} ATR(50)/Mov(C,50,S)>=0.01 AND ATR(50)/Mov(C,50,S)<=0.025 AND
{3} Mov(C,50,S)*Mov(V,50,S)>=500000 AND
{5} Mov(C,200,S) - Ref(Mov(C,200,S),-50) > 3 * ATR(200) AND
{5.1} Mov(C,200,S) - Ref(Mov(C,200,S),-50) < 5 * ATR(200) AND
{6} BarsSince((Mov(C,5,S) - Ref(Mov(C,5,S),-1))<0) < 3,-1) AND
L<=LE;
LongEntryTrigger;

Example code using TradeSim formulas (as an indicator):

{=== BACKTEST 00GKLR ===}
{=== Created with Template V1.0 ===}
{=== 30 Jan 2006 ===}

{=== INITIALISE VARIABLES ===}

DayStart := 1; MonthStart := 1; YearStart := 2006;
DayStop := 28; MonthStop := 4; YearStop := 2006;

{=== LONG TRADES ===}

LE := Ref(C+1.0*ATR(50),-1);

LongEntryTrigger :=
{T} Ref(Cross(C,Ref(HHV(H,3),-1)) AND
{1} C>=0.5 AND C <= 20.0 AND
{2} ATR(50)/Mov(C,50,S)>=0.01 AND ATR(50)/Mov(C,50,S)<=0.025 AND
{3} Mov(C,50,S)*Mov(V,50,S)>=500000 AND
{5} Mov(C,200,S) - Ref(Mov(C,200,S),-50) > 3 * ATR(200) AND
{5.1} Mov(C,200,S) - Ref(Mov(C,200,S),-50) < 5 * ATR(200) AND
{6} BarsSince((Mov(C,5,S) - Ref(Mov(C,5,S),-1))<0) < 3,-1) AND
L<=LE;

LongEntryPrice := If(O<LE,O,LE);

LongInitialStop := LongEntryPrice-Ref(2*ATR(50)-.001,-1);

LongExitTrigger :=
{1} ExtFml("TradeSim.TrailingStop",Trigger,Long,2*ATR(10)-.001,H,C) OR
{2} H>=Ref((BBandTop(C,10,S,2)+2*ATR(10)),-1);

LongExitPrice := OPEN;

dummy:= ExtFml("TradeSim.Initialize");
dummy:= ExtFml("TradeSim.SuppressFileProcessing");
dummy:= ExtFml("TradeSim.SetReturnInfoType",ALLTRIGGERS);
dummy:= ExtFml( "TradeSim.GetSymbolLength") =3;
dummy:= ExtFml("TradeSim.SetStartRecordDate",DayStart,MonthStart,YearStart);
dummy:= ExtFml("TradeSim.SetStopRecordDate",DayStop,MonthStop,YearStop);
dummy:= ExtFml("TradeSim.EnableDelayOfAllExitsByOneBar");
dummy:= ExtFml("TradeSim.EnableProtectiveStop",0);
dummy:= ExtFml("TradeSim.UseClosingPriceAsStopThreshold");
dummy:= ExtFml("TradeSim.EnableTradePyramiding",Trigger,0,100);
ExtFml("TradeSim.RecordTrades","00GKLR 060327", Long,LongEntryTrigger,LongEntryPrice,LongInitialSt op,LongExitTrigger,LongExitPrice,Start);


TradeSim Exploration:

{=== BACKTEST 00GKLR ===}
{=== Created with Template V1.0 ===}
{=== 30 Jan 2006 ===}

{=== INITIALISE VARIABLES ===}

DayStart := 1; MonthStart := 1; YearStart := 2006;
DayStop := 28; MonthStop := 4; YearStop := 2006;

{=== LONG TRADES ===}

LE := Ref(C+1.0*ATR(50),-1);

LongEntryTrigger :=
{T} Ref(Cross(C,Ref(HHV(H,3),-1)) AND
{1} C>=0.5 AND C <= 20.0 AND
{2} ATR(50)/Mov(C,50,S)>=0.01 AND ATR(50)/Mov(C,50,S)<=0.025 AND
{3} Mov(C,50,S)*Mov(V,50,S)>=500000 AND
{5} Mov(C,200,S) - Ref(Mov(C,200,S),-50) > 3 * ATR(200) AND
{5.1} Mov(C,200,S) - Ref(Mov(C,200,S),-50) < 5 * ATR(200) AND
{6} BarsSince((Mov(C,5,S) - Ref(Mov(C,5,S),-1))<0) < 3,-1) AND
L<=LE;

LongEntryPrice := If(O<LE,O,LE);

LongInitialStop := LongEntryPrice-Ref(2*ATR(50)-.001,-1);

LongExitTrigger :=
{1} ExtFml("TradeSim.TrailingStop",Trigger,Long,2*ATR(10)-.001,H,C) OR
{2} H>=Ref((BBandTop(C,10,S,2)+2*ATR(10)),-1);

LongExitPrice := OPEN;

ExtFml("TradeSim.Initialize");
ExtFml( "TradeSim.GetSymbolLength") =3;
ExtFml("TradeSim.SetStartRecordDate",DayStart,MonthStart,YearStart);
ExtFml("TradeSim.SetStopRecordDate",DayStop,MonthStop,YearStop);
ExtFml("TradeSim.EnableDelayOfAllExitsByOneBar");
ExtFml("TradeSim.EnableProtectiveStop",0);
ExtFml("TradeSim.UseClosingPriceAsStopThreshold");
ExtFml("TradeSim.EnableTradePyramiding",Trigger,0,100);
ExtFml("TradeSim.RecordTrades","00GKLR 060327", Long,LongEntryTrigger,LongEntryPrice,LongInitialSt op,LongExitTrigger,LongExitPrice,Start);


All help greatly appreciated. :?

Cheers,
Pat