logo
Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

Options
Go to last post Go to first unread
Adrenaline  
#1 Posted : Tuesday, March 6, 2012 11:40:54 AM(UTC)
Adrenaline

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))
jjstein  
#2 Posted : Wednesday, March 7, 2012 12:28:13 AM(UTC)
jjstein

Rank: Advanced Member

Groups: Registered, Registered Users, Subscribers
Joined: 5/13/2005(UTC)
Posts: 715
Location: Midwest, USA

Was thanked: 1 time(s) in 1 post(s)
Adrenaline wrote:
At the bottom is one of the Chandelier exits i have entered my MS11 indicator list.

<prev,stlong,max(stlong,prev)); stopshort:="If(C">
Well, first things first: Your code isn't posting correctly (see "stopLong").

HOW TO POST CODE. Put your code between these two lines, but take out the space after the first asterisk:

* code*
Put your code here.
* /code*

So it looks like this:

Code:


Put your code here.





Adrenaline wrote:
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.


Well, you get an "E" for Effort, then<g>...I have to agree that TradeSim documentation is a COMPLETE DISASTER as a User Manual. It's OK as a Reference Manual (but is obviously written by a Programmer for other Programmers, as a Programmer's Manual).

At any rate, it sounds like you need to get clear on just what Stops are supposed to do, then adjust your thinking to be in line with how TradeSim uses Stops (Initial and Trailing).

Example: Use a 10% stop (for a LONG trade). That could mean a bunch of things, but let's set it to 10% below the current LOW price, and watch for the CLOSE to penetrate. In this case, the Initial Stop and Trailing Stop are IDENTICAL at 10%. In TradeSim terms (AN2), this is:

Reference: LOW price
Volatility: 10%
Threshold: CLOSE price (The AN2 example uses the LOW, though)

Bear in mind that there is an ASSUMPTION behind the whole idea of a Trailing Stop: By definition, and no-matter-what, it NEVER goes down; it's value will either stay the same, or go higher.

You can easily imagine some variations, like an Initial Stop of 5% (in case you're wrong about the trade), then keep the Trailing Stop of 10% if you stay in the trade.

Usually, for any given "Trading System" you are testing, you implement at least an Entry, an Exit and usually a Stop, perhaps divided into an Initial Stop and Trailing Stop. Whether you do that all-in-one or in separate pieces is your choice/habit.

But, you should note that TradeSim will want to know your Initial Stop, as it uses it to control position size and/or risk. Make sure you are ABSOLUTELY CLEAR about that use of Initial Stop, otherwise things will go on behind your back that you do not understand during the simulation, but which you MUST know, in order to actually place a trade that is in accordance with your simulation!

Use of a Trailing Stop in TradeSim is simple -- it just becomes part of the ExitTrigger logic.



Adrenaline wrote:
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?


As noted earlier, the code didn't come through, but from what you posted, it looks you want to use a Chandelier Stop as your ONLY exit, so something like this should work:
Code:

Threshold:=Low; { Could be Low, Close, Median, etc. }
ExitTrigger:=Cross(Fml( "ATR Chandelier Exit"),Threshold);
wabbit  
#3 Posted : Wednesday, March 7, 2012 2:07:50 AM(UTC)
wabbit

Rank: Advanced Member

Groups: Registered, Registered Users, Subscribers, Unverified Users
Joined: 10/28/2004(UTC)
Posts: 3,106
Location: Perth, Western Australia

Was thanked: 12 time(s) in 12 post(s)
I'm not a TradeSim user per se, but I reckon this should come close?

Code:

EntryTrigger:= {your LONG entry conditions};
EntryPrice:=OPEN;



Volatility:=2 * ATR(13);

{close the LONG trade, if the LOW price is below CLOSE - VOLATILITY}

ExitTrigger:=ExtFml( "TradeSim.TrailingStop",
TRIGGER,
LONG,
Volatility,
CLOSE,
LOW);

{exit the trade at the SL price (hopefully)}
ExitPrice:=ExtFml( "TradeSim.TrailingStop",
BAND,

LONG,

Volatility,

CLOSE,

LOW);

InitialStop := 0;

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


 "Trailing Exit System Test",


 LONG,


 EntryTrigger,


 EntryPrice, 


 InitialStop, 


 ExitTrigger,


 ExitPrice,


 START);







wabbit [:D]

Adrenaline  
#4 Posted : Wednesday, March 7, 2012 10:50:47 AM(UTC)
Adrenaline

Rank: Member

Groups: Registered, Registered Users
Joined: 4/21/2005(UTC)
Posts: 25
Location: Los Angeles, CA

I love you guys!! Thank you very much. Big BIG help..
Users browsing this topic
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.