PureBytes Links
Trading Reference Links
|
> In 'Bonus Issue' (no month) 1993, the Technical Analysis of Stocks &
>Commodities magazine carried an article by Technical Editor John Sweeney,
>describing his 'Maximum Adverse Excursion' (MAE) concept.
Yes, I did some experiments with this myself.
> The idea being that if you looked at, say, 30 of your trades that went
>well, and for each one you figured out how much it went against you, then
>in future trades it would be wise to place your stops just big enough that
>this adverse excursion could happen without triggering the stop and
>throwing you out of the trade.
Ideally what you do is look at the distributions of MAE for the
winning trades and the losing trades. You will notice that the
winning trades will have some MAE (including the average and a
standard deviation) that is less than the average MAE for the
losers. The idea is to determine the multiple of average true range
(ATR) of the winning-trade MAE, and use that as your initial stop.
This stop is going to be less than your usual initial stop, and your
risk is thereby reduced.
That's the theory. In practice, I have found it doesn't work as
well as you'd think. I found this puzzling at first. What happens
is that some losers end up losing more money from stopping out
too early, reducing the overall expectancy of the system. These
particular losers are the ones that go as far as the winning-trade
MAE, and if allowed to run they recover a bit before getting stopped
out by the normal trailing stop.
> So has anybody worked out an Easy-Language procedure that can scan a
>length of years and calculate the Maximum Adverse Excursion?
Just so happens, I have. Here it is. Just put a call to this
function in your signal. The function gets executed every bar,
recording the market noise (ATR), the entry prices, the exit prices,
your initial stop, the MAE during a position, and when a position is
exited it outputs a line to a file, which you can load into Excel.
This gives you a history of trades with all the useful statistics
you need for position sizing and such.
-----------------------------------------------------------------
{_SystemHistory
by Alex Matulich, Unicorn Research Corporation, June 2002
Don't call this function during an optimization!
It will produce a huge file.
This function Output the profit, initial risk, initial volatility,
and maximum adverse excursion (MAE) for every closed position.
Units output are in dollars, not market units, although inputs
*are* in market units.
This function assumes only one position is open at a time.
No pyramiding.
}
inputs:
filename(string), {full pathname for .csv file}
{WARNING: avoid \hb, \he, \pb, \pe, \wb, or \we, in the file
name. TS interprets these as "jump commands." For example,
the filenames "c:\hello.csv" or "c:\data\performance.csv" will
result in an error message because they contain \he and \pe,
respectively.}
tstop(NumericSeries), {current stop}
mktvolatility(NumericSeries), {current volatility (ATR)}
execute_next_bar(TrueFalse); {true=entry from previous bar's order;
set to true if you use "next bar" orders}
vars: risk(0), mktvolat(0), nclosed(0), MAE(0);
if StrLen(filename) > 0 then begin
{Initializations to occur on first bar}
if currentbar <= 1 then nclosed = 0;
{Do the following while a position is open}
if marketposition<>0 then begin
if BarsSinceEntry=0 then begin {first bar of the open position}
if execute_next_bar then begin
risk = AbsValue(EntryPrice - tstop[1]) * BigPointValue;
mktvolat = mktvolatility[1] * BigPointValue;
if marketposition>0 then
MAE = MinList(BigPointValue*(Low - EntryPrice), 0)
else
MAE = MinList(BigPointValue*(EntryPrice - High), 0);
end else begin
MAE = MinList(positionprofit, 0);
risk = AbsValue(EntryPrice - tstop) * BigPointValue;
mktvolat = mktvolatility * BigPointValue;
end;
end else begin {we're past the first bar in the open position}
risk = risk[1]; {save initial risk}
mktvolat = mktvolat[1]; {save initial volatility}
if marketposition>0 then {calculate new MAE}
MAE = MinList(MAE[1], BigPointValue*(Low - EntryPrice), 0)
else
MAE = MinList(MAE[1], BigPointValue*(EntryPrice - High), 0);
end;
end;
nclosed = nclosed[1];
{Do the following whenever a position is closed}
if totaltrades > nclosed then begin
FileAppend(filename,
numtostr(PositionProfit(1),2)+","+ {output profit}
numtostr(risk[1],2)+","+ {output initial risk}
numtostr(mktvolat[1],2)+","+ {output initial volatilty}
numtostr(MinList(MAE[1],positionprofit(1)),2) {output MAE}
+NewLine);
nclosed = totaltrades;
end;
end;
_SystemHistory = 1; {dummy return value}
--
,|___ Alex Matulich -- alex@xxxxxxxxxxxxxx
// +__> Director of Research and Development
// \
// __) Unicorn Research Corporation -- http://unicorn.us.com
|