Rank: Member
Groups: Registered, Registered Users Joined: 4/21/2005(UTC) Posts: 25 Location: Los Angeles, CA
|
Posted this on the Tradesim forum as well.
I've been reading as much as I can and cannot figure out for the life of me figure out how to add the Chandelier Exit to my tradesim code. I've read the AN2-Trailing Stop PDF but it just doens't make any sense to me. I'm not the brightest star in the sky when it comes to comprehending some things but I have really been trying to figure it out before asking.
At the bottom is one of the Chandelier exits i have entered my MS11 indicator list.
Can anyone tell me where and what to add in my code to get this exit added?
Any help would be GREATLY appreciated as i've seem to hit a brick wall in my system development.
Thank you...
Code:
Not 100% sure what goes here above my Entry but was trying this.
multi:=3;
pds:=13;
pds1:=21;
plot:=1;
adv:=0;
delay:=0;
EntryTrigger:= "My Entry Code";
EntryPrice:=OPEN;
ExitTrigger:=Fml( "ATR Chandelier Exit") ;
Not sure what goes here.
ExitPrice:=OPEN;
InitialStop:=Ref(C-2*ATR(13),-1);
ExtFml( "Tradesim.Initialize") ;
ExtFml( "Tradesim.EnableDelayOfEntryByOneBar") ;
ExtFml("Tradesim.EnableDelayOfAllExitsByOneBar");
ExtFml( "Tradesim.EnableProtectiveStop",1) ;
ExtFml("Tradesim.SetStartRecordDate",03,01,2005);
ExtFml("Tradesim.SetStopRecordDate",03,01,2012);
ExtFml( "TradeSim.RecordTrades",
"System test",
LONG,
EntryTrigger,
EntryPrice,
InitialStop,
ExitTrigger,
ExitPrice,
START);
Code:
{ Trailing Stop - ATR Chandelier Exit v3.0
Copyright © 2003-2007 Jose Silva. }
{ User Inputs }
multi:=Input("ATR multiplier",0,10,2.5);
pds:=Input("ATR periods",1,252,10);
pds1:=Input("ATR lookback periods",1,252,21);
plot:=Input("[1]Trailing Stop, [2]Long+Short, [3]Signals",1,3,1);
adv:=Input("plot: today's trailing stop=0, tomorrow's stop=1",0,1,0);
delay:=Input("Entry and Exit signal delay",0,5,0);
{ Trailing Stops }
StLong:=HHV(C-multi*Mov(ATR(1),pds,E),pds1);
StShort:=LLV(C+multi*Mov(ATR(1),pds,E),pds1);
stopLong:=If(C<prev,StLong,Max(StLong,PREV));
stopShort:=If(C>PREV,StShort,Min(StShort,PREV));
{ Trade flags/signals }
In:=Cross(C,Ref(stopShort,-1));
Out:=Cross(Ref(stopLong,-1),C);
Init:=Cum(IsDefined(In+Out))=1;
x:=ValueWhen(1,In-Out0 OR Init,In-Out);
long:=x=1 AND (Alert(x1,2) OR Init);
short:=x=-1 AND (Alert(x-1,2) OR Init);
signals:=long-short;
flag:=ValueWhen(1,signals0 OR Init,signals);
{ Switch between Long/Short stops }
stop:=Ref(If(flag=1,stopLong,stopShort),-1+adv);
{ Plot in price chart }
If(plot=1,stop,
If(plot=2,Ref(stopLong,-1+adv),0));
If(plot=1,stop,
If(plot=2,Ref(stopShort,-1+adv),signals))
|