PureBytes Links
Trading Reference Links
|
Hi,
Below 3 formulas from the Guppy site (written by Glen Wallace, Ian Burgoyne & David Bozkurtian):
Chandelier Exit
The exit system you use is at least as important as the entry system.
Below is the code for Chuck LeBeau's Chandelier Exit. The Chandelier Exit is a volatility based exit (it uses average true range) that works quite well on trend following systems. It lets "... profits run in the direction of a trend while still offering some protection against any reversal in trend."
The theory is quite simple, but because of the awkwardness of defining the entry price, its implementation in MetaStock takes some work. The theory is: exit a long position at either the highest high since entry minus 3 ATRs, or at the highest close since entry minus 2.5 ATRs.
The exit is descibed more fully in the Trader's Toolkit section at Chuck LeBeau's site -- http://traderclub.com/
Here is the MetaStock code:
{LONG EXIT}
LongEntry:= {this your entry system, eg. Cross(CLOSE, Mov(C,20,E))};
MoneyMgmtStop:= {this is your maximum loss, in points};
{DEFINE ENTRY PRICE, WITH EXIT BEING -ENTRY PRICE AND NO TRADE BEING 0}
EntryPrice:= If(PREV <= 0,
{Trade entered today?}
If(LongEntry, CLOSE, 0),
{Trade entered before today. Stopped today?}
If(LOW <= PREV - MoneyMgmtStop, -PREV,
If(LOW <= HighestSince(1,PREV=0, HIGH) - 3 * ATR(10), -PREV,
If(LOW <= HighestSince(1,PREV=0, CLOSE) - 2.5 * ATR(10), -PREV,
PREV))));
{EXIT IF ENTRY PRICE < 0 (MEANING EXIT)}
EntryPrice < 0
{SHORT EXIT}
ShortEntry:= {this your entry system, eg. Cross(Mov(C,20,E), CLOSE)};
MoneyMgmtStop:= {this is your maximum loss, in points};
{DEFINE ENTRY PRICE, WITH EXIT BEING -ENTRY PRICE AND NO TRADE BEING 0}
EntryPrice:= If(PREV <= 0,
{Trade entered today?}
If(ShortEntry, CLOSE, 0),
{Trade entered before today. Stopped today?}
If(HIGH >= PREV + MoneyMgmtStop, -PREV,
If(HIGH >= LowestSince(1,PREV=0, LOW) + 3 * ATR(10), -PREV,
If(HIGH >= LowestSince(1,PREV=0, CLOSE) + 2.5 * ATR(10), -PREV,
PREV))));
{EXIT IF ENTRY PRICE < 0 (MEANING EXIT)}
EntryPrice < 0
{from Glen Wallace}
.........................................................
Chandelier Exit 2
Here is the Fast Chandelier Exit in full as supplied to me. It is part of an exit strategy which you can adjust to your own trading style and comfort levels.
HHVDays:=Input("Days Since Trade Opened",1,300,1);
ATRDays:=Input("ATR Days",1,30,10);
ATRHighMult:=Input("ATR Multiplier From High",1,5,3.0);
ATRCloseMult:=Input("ATR Multiplier From Close",1,5,2.5);
HHVStop:= HHV(H,HHVDays) - ATRHighMult*ATR(ATRDays);
HighStop:= H - ATRHighMult*ATR(ATRDays);
CloseStop:= C - ATRCloseMult*ATR(ATRDays);
TodaysCalc:= If(HighStop > CloseStop, HighStop, CloseStop);
TodaysStop:= If(L <= PREV, TodaysCalc, If(HHVStop < PREV, PREV,
If(HHVStop > C,PREV,HHVStop)));
HHVDays:=Input("Days Since Trade Opened",1,300,1);
ATRDays:=Input("ATR Days",1,30,10);
ATRHighMult:=Input("ATR Multiplier From High",1,5,3.0);
ATRCloseMult:=Input("ATR Multiplier From Close",1,5,2.5);
HHVStop:= HHV(H,HHVDays) - ATRHighMult*ATR(ATRDays);
HighStop:= H - ATRHighMult*ATR(ATRDays);
CloseStop:= C - ATRCloseMult*ATR(ATRDays);
TodaysCalc:= If(HighStop > CloseStop, HighStop, CloseStop);
TodaysStop:= If(L <= PREV, TodaysCalc, If(HHVStop < PREV, PREV,
If(HHVStop >C,PREV,HHVStop)));
TodaysStop
[from Ian Burgoyne}
.......................................................
A few weeks ago when the Chandelier Exit was posted to our board, I asked if there was a faster version of it. On my (slowpoke) 200 Mhz PC at home, it took about 1 to 2 minutes to calculate the formula on a single stock.
Anyway, I did not hear of any feasible solutions. Last night, upon reading about the 25X25 system on this site, it struck me that the original Chandelier Exit (see below) had a whole bunch of PREV statements in it. I'm sure everyone knows where I'm going with this by now.
Anyway, here is how the code (at least this iteration) should be modified to speed up the calculation by a factor of 5. Basically, we move PREV into a variable vPREV prior to using it (so that it is only calculate once) in the long and short exits. Here is the code for the long exit. I tested it with the sample Entry Rule and receive the same results in 1/5th the time. Just modify the SHORT exit in the same way. Hope this helps everyone using it.
{DEFINE ENTRY PRICE, WITH EXIT BEING -- ENTRY PRICE AND NO TRADE BEING 0}
{Move PREV into a variable to speed things up - DB 2/17/00}
vPREV:=PREV;
EntryPrice:= If(vPREV <= 0,
{Trade entered today?}
If(LongEntry, CLOSE, 0),
{Trade entered before today. Stopped today?}
If(LOW <= vPREV - MoneyMgmtStop, -vPREV,
If(LOW <= HighestSince(1,vPREV=0, HIGH) - 3 * ATR(10), -vPREV,
If(LOW <= HighestSince(1,vPREV=0, CLOSE) - 2.5 * ATR(10), -vPREV, vPREV))));
{from David Bozkurtian}
.......................................................
Regards,
Staffan
----- Original Message -----
From: <CBranco@xxxxxxxxxxxxxxxxxxxxxx>
To: <metastock@xxxxxxxxxxxxx>
Sent: Monday, September 10, 2001 3:39 PM
Subject: Chandelier Exit
> Anyone had a go at a formula for the Chandelier Exit as indicator in
> Metastock ?
>
> Thanks.
>
|