bbattlej
23rd August 2004, 08:09 AM
I am trying to buy on the open of the day after my trigger.
Set an atr stoploss below my entry price.
Set a trailing stop that will follow the highest high since entering the trade and exit my trade at the price it is breached.
The problem is that when I run my code the trade enters and exits on the day.
My code is:
LongEntryTrigger := Cross(Stoch(10,3),Mov(Stoch(10,3),3,E))
AND
ATR(10)/C>=0.02 AND ATR(10)/C<=0.1
AND
C>=1 AND C <= 10
AND
Mov(C,21,S)*Mov(V,21,S)>=100000
AND
Mov(C,200,S)>=Ref(Mov(C,200,S),-50)+6*ATR(200);
LongEntryPrice := OPEN;
LongExitTrigger:= ExtFml("TradeSim.TrailingStop", trigger, long, 10*ATR(10),H,L);
LongExitPrice:=
Ref(ExtFml("TradeSim.TrailingStop",band, long, 10*ATR(10),H,L),-1);
LongExitPrice:=If(LongExitPrice>O,O,LongExitPrice);
LongExitPrice:=If(LongExitPrice<L,L,LongExitPrice);
LongInitialStop:=LongEntryPrice -Ref(10*ATR(10),-1);
ExtFml( "TradeSim.Initialize") ;
ExtFml( "TradeSim.RecordTrades",
"jbsys 011",
LONG,
LongEntryTrigger,
LongEntryPrice,
LongExitTrigger,
LongInitialStop,
LongExitPrice,
Start )
Set an atr stoploss below my entry price.
Set a trailing stop that will follow the highest high since entering the trade and exit my trade at the price it is breached.
The problem is that when I run my code the trade enters and exits on the day.
My code is:
LongEntryTrigger := Cross(Stoch(10,3),Mov(Stoch(10,3),3,E))
AND
ATR(10)/C>=0.02 AND ATR(10)/C<=0.1
AND
C>=1 AND C <= 10
AND
Mov(C,21,S)*Mov(V,21,S)>=100000
AND
Mov(C,200,S)>=Ref(Mov(C,200,S),-50)+6*ATR(200);
LongEntryPrice := OPEN;
LongExitTrigger:= ExtFml("TradeSim.TrailingStop", trigger, long, 10*ATR(10),H,L);
LongExitPrice:=
Ref(ExtFml("TradeSim.TrailingStop",band, long, 10*ATR(10),H,L),-1);
LongExitPrice:=If(LongExitPrice>O,O,LongExitPrice);
LongExitPrice:=If(LongExitPrice<L,L,LongExitPrice);
LongInitialStop:=LongEntryPrice -Ref(10*ATR(10),-1);
ExtFml( "TradeSim.Initialize") ;
ExtFml( "TradeSim.RecordTrades",
"jbsys 011",
LONG,
LongEntryTrigger,
LongEntryPrice,
LongExitTrigger,
LongInitialStop,
LongExitPrice,
Start )