PDA

View Full Version : Debugging Problems


dilmun99
14th June 2004, 06:54 PM
Hi.
I am using the dummy procedure to debug my code for a straightforward long and short system with random entry and ATR based trailing stops. The long side seems to be working fine, but the short side is giving me several entries before the first exit. I can't work out what I'm doing wrong. Here's the exit code as I have it in the Expert Adviser. The "long" entry/exit portions have been commented out for debugging purposes.

ARC:=3;
Period:=10;
Volatility:=ARC*ATR(Period);
BandLong:=ExtFml("TradeSim.TrailingStop",BAND, LONG,Volatility,CLOSE,LOW);
BandShort:=ExtFml("TradeSim.TrailingStop",BAND, SHORT,Volatility,CLOSE,HIGH);

{LongEntryTrigger := ExtFml("TradeSim.Rand")<0.1;
LongEntryPrice := OPEN;
LongExitTrigger := (L<=Ref(BandLong,-1));
LongExitPrice := OPEN;
LongInitialStop:= CLOSE - ARC*ATR(Period);

Dummy:=ExtFml("TradeSim.Initialize");
Dummy:=ExtFml("TradeSim.SuppressFileProcessing");
Dummy:=ExtFml("TradeSim.SetReturnInfoType",ExitTriggers);

ExtFml("TradeSim.EnableDelayOfEntryByOneBar");
ExtFml("TradeSim.EnableDelayOfAllExitsByOneBar");
ExtFml("TradeSim.EnableProtectiveStop",1);
ExtFml("TradeSim.SetStartRecordDate", 1, 1, 1997);
ExtFml("TradeSim.SetStopRecordDate", 1, 1, 2003);
ExtFml("TradeSim.SetStopGapPriceToOpen");

ExtFml( "TradeSim.RecordTrades",
" LS Template",
LONG,
LongEntryTrigger,
LongEntryPrice,
LongInitialStop,
LongExitTrigger,
LongExitPrice,
START); }

ShortEntryTrigger := ExtFml("TradeSim.Rand")<0.1;
ShortEntryPrice := OPEN;
ShortExitTrigger := (H>=Ref(BandShort,-1));
ShortExitPrice := OPEN;
ShortInitialStop:=CLOSE + ARC*ATR(Period);

Dummy:=ExtFml("TradeSim.Initialize");
Dummy:=ExtFml("TradeSim.SuppressFileProcessing");
Dummy:=ExtFml("TradeSim.SetReturnInfoType",ExitTriggers);
ExtFml("TradeSim.EnableDelayOfAllExitsByOneBar");
ExtFml("TradeSim.EnableProtectiveStop",1);
ExtFml("TradeSim.SetStartRecordDate", 1, 1, 1997);
ExtFml("TradeSim.SetStopRecordDate", 1, 1, 2003);
ExtFml("TradeSim.SetStopGapPriceToOpen");

ExtFml( "TradeSim.RecordTrades",
" LS Template",
SHORT,
ShortEntryTrigger,
ShortEntryPrice,
ShortInitialStop,
ShortExitTrigger,
ShortExitPrice,
START); {CONTINUE changed to START for debugging}

(is this best posted here on in the coding section? - let me know which is better)

Thanks
Andrew

David Samborsky
15th June 2004, 05:19 AM
When debugging you should separate the long and short sections into two individual indicators.

Also assign the dummy variables to all of the ExtFml formulas except for the RecordTrades call.

dilmun99
15th June 2004, 10:54 AM
Thanks David

If I have to assign dummy variables to all the ExtFml functions then I can't debug the trade delay or initial stop functions - ie I can't do a visual inspection to see if they are working correctly. Is that correct?

I'm sure that your to-do list is a long one, but this might be something to add. I may be unusualy anal in this, but I like to do a visual inspection of the t rades generated by a system, exactly as sent to the back-tester.

Best
Andrew