kozerog
4th August 2006, 02:10 AM
Please help
Hi, I have the following code and my trailing stops are not being executed properly.
It seems that the reference for the trailing stops, (which is based on close)
is taken even prior to the EntryTrig (which I don't want to happen)
I want the trailing stop to be computed after the last trade is exited and the new trade is entered.
Please take a look
F2:=ValueWhen(1,L>Ref(L,-2) AND Ref(L,-1)>Ref(L,-2) AND Ref(L,-3)>Ref(L,-2) AND Ref(L,-4)>Ref(L,-2),Ref(L,-2));
EntryTrig:=Cross(F2,L) AND H>f2; {no gaps}
EntryPrice:=C;
Stop:=ExtFml("tradesim.trailingstop",
band,
short,
c*0.1 {10% trailing stop},
C,
H);
stop1:=Ref(stop, -1); {prev stop applies today}
stop2:=Cross(H, stop1); {trigger}
InitialStops:= entryprice*1.1;
ExitPrice:=If(stop2, If(O>stop1, O, stop1), If(O>initialstops, O, initialstops));
ExtFml("Tradesim.initialize");
ExtFml("Tradesim.setstartrecorddate",1,1,1995);
ExtFml("Tradesim.setstoprecorddate",1,3,2000);
ExtFml("tradesim.enableprotectivestop",1);
ExtFml("TradeSim.SetExitTriggerDelay",1);
ExtFml( "TradeSim.RecordTrades",
"01_FRACTAL",
short,
EntryTrig,
EntryPrice,
InitialStops,
stop2,
Exitprice,
START);
Hi, I have the following code and my trailing stops are not being executed properly.
It seems that the reference for the trailing stops, (which is based on close)
is taken even prior to the EntryTrig (which I don't want to happen)
I want the trailing stop to be computed after the last trade is exited and the new trade is entered.
Please take a look
F2:=ValueWhen(1,L>Ref(L,-2) AND Ref(L,-1)>Ref(L,-2) AND Ref(L,-3)>Ref(L,-2) AND Ref(L,-4)>Ref(L,-2),Ref(L,-2));
EntryTrig:=Cross(F2,L) AND H>f2; {no gaps}
EntryPrice:=C;
Stop:=ExtFml("tradesim.trailingstop",
band,
short,
c*0.1 {10% trailing stop},
C,
H);
stop1:=Ref(stop, -1); {prev stop applies today}
stop2:=Cross(H, stop1); {trigger}
InitialStops:= entryprice*1.1;
ExitPrice:=If(stop2, If(O>stop1, O, stop1), If(O>initialstops, O, initialstops));
ExtFml("Tradesim.initialize");
ExtFml("Tradesim.setstartrecorddate",1,1,1995);
ExtFml("Tradesim.setstoprecorddate",1,3,2000);
ExtFml("tradesim.enableprotectivestop",1);
ExtFml("TradeSim.SetExitTriggerDelay",1);
ExtFml( "TradeSim.RecordTrades",
"01_FRACTAL",
short,
EntryTrig,
EntryPrice,
InitialStops,
stop2,
Exitprice,
START);