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
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