. 7
( 9)


Below are the steps involved in evolving an entry model based on the rule tem-
plates being used in this study:
1. Retrieve a 12-element chromosome from the genetic optimizer compo-
nent. This represents a potential solution, one that initially will be ran-
dom and probably not very good.
2. Instantiate the rule templates to obtain three fully defined rules (one for
each gene), and compote their TRUE/FALSE values for all bars in the
data series, based upon the decoding of the genes/chromosome.
3. Proceed bar by bar through the data. If, on a given bar, all three instanti-
ated rules evaluate to TRUE, and if there is no current long (or short)
position, then post an order to the simulator component to buy (or sell)
at tomorrow™s open.
4. If a position is being held, use the standard exit strategy to handle the
5. Evaluate the trading performance of the potential solution. For this exer-
cise, the basic “goodness” of a solution is defined as the annualized risk-
to-reward ratio, a figure that is actually a resealed t-statistic.
6. Tell the genetic optimizer how fit (in the above sense) the potential solu-
tion (the chromosome it provided) was. This allows the genetic optimiz-
er component to update the population of chromosomes it maintains.
7. If the solution meets certain criteria, generate performance summaries
and other information, and save this data to a file for later perusal.
8. Repeat the above steps again and again until a sufficient number of
“generations” have passed.
As the above steps are repeated, the solutions, i.e., the “guesses” (actually, “off-
spring”), provided by the genetic optimizer, will get better and better, on average.
Because of the way the genetic process works, large numbers of distinct, yet effec-
tive, solutions will emerge during the evolutionary process. Most of the solutions
will have been recorded in a tile generated in the course of repeatedly performing
the first seven computational steps. In the “Code” section of this chapter, a dis-
cussion can be found of some of the C++ code that actually implements the
above steps, including the instantiation and computation of the rules.
Because of the nature of the rules, asymmetries are likely. Consequently,
long entry models are evolved and tested separately from short entry models.
Model performance is evaluated on the entire portfolio. The goal is to find a set of
rules that, when applied in the same way to every tradable, produce the best over-
all portfolio performance. The procedure being used here differs from the one in
our earlier investigation (Katz and McCormick, February 1997) where sets of
rules, specific to each of several markets, were evolved, an approach that was
much more subject to the effects of curve-fitting. As observed with several other
models that were originally tested on individual tradables, some performance may
be lost when requiring a common model across all markets without market-spe-
cific optimization or tuning. In the tests that follow, the standard C+ + software
platform, as well as the standard entry orders and exit strategy, are used.
EventPresent Cint *es. int m, int cb) (
static int
// Used by the Rules function to simplify coding
int i ;
forti=cb-m+l; ic=cb; i++)
CHAPTER 12 Genetic Algorithma:
,, instruct Simulator to employ standard exit strategy
tmp = exitatr[cbl ;
tS.StdeXitdSC'X', ptlim*tmp, mmstp*tmp, maxholdi ;

) /I process next bar

The Cf + code implements the rule templates and system trading strategy. The
function Rules implements the rule templates. Arguments vl, ˜2, ˜3, and v4
(which correspond to the four numbers that comprise any one of the three genes)
provide all the information required to instantiate a rule template. Argument vl is
used to select, via a “switch statement,” the required rule template from the 10 that
are available; arguments ˜2, ˜3, and ˜4, are used to till in the blanks (required
parameters, desired directions of comparison, etc.) to yield a fully defined rule.
The rule is then immediately evaluated for all bars, and the evaluations (1 for
TRUE, 0 for FALSE) are placed in ans, a floating-point vector used to return the
results to the caller.
The macro, BiasedPosScaZe(x,n), is used to map numbers ranging from 0 to
1,000 to a range of 0 to a, with more numbers mapping to smaller values than
larger ones. The macro is used to compute such things as lookbacks and moving-
average periods from ˜2, ˜3, or ˜4, the values of which are ultimately derived
from the genetic algorithm and scaled to range from 0 to 1,000. The macro is non-
linear (Biased) so that a finer-grained exploration occurs for smaller periods or
lookbacks than for larger ones. For example, suppose there is a moving average,
with a period that ranges from 2 to 100 bars. The intention is to search as much
between periods 2, 3, and 4 as between 30, 50, and 90; i.e., the scale should be
spread for small numbers. This is desired because, in terms of trading results, the
change from a 2.bar moving average to a 5-bar moving average is likely to be
much greater than the change from a 50-bar to a 60.bar moving average.
The macro, LinearScnle(x,a,b), performs a linear mapping of the range 0
1,000 to the range a b. The macro is usually used when calculating
thresholds or deviations. In the rule template code, all parameters are scaled
inside Rules, rather than inside the GA as is the usual practice. The GA has
been instructed to produce numbers between 0 and 1,000, except for chromo-
some elements 1, 5, and 9, which are the first numbers in each gene, and which
serve as rule template selectors. The reason for local scaling is that templates
for different kinds of rules require parameter and control values having differ-
ent ranges to be properly instantiated.
The process of evolving trading systems involves asking the genetic opti-
mizer to provide a “guess” as to a chromosome. The genetic optimizer then ran
domly picks two members of the population and mates them (as specified by the
crossover, mutation rate, and chunk-size properties). The resultant offspring is
then returned as a potential solution. When the GA component is told the fitness
of the solution it has just provided, it compares that fitness with that of the least-
fit member of the population it maintains. If the fitness of the offspring is greater
than the fitness of the least-fit member, the GA replaces the least-fit member with
the offspring solution. This process is repeated generation after generation, and is
handled by the shell code (not shown), which, in turn, makes repeated calls to
function Model to simulate the trading and evaluate the system™s fitness.
The code for function Model is almost identical to that used in earlier chap-
ters. Prior to the bar indexing loop in which trading orders are generated, the func-
tion R&s is invoked three times (once for each gene), with the results being
placed in time series rulel, ruZe2, and n&3. A 50.bar average true range is also
calculated, as it is necessary for the standard exit and for rule evaluation. Inside
the loop, the rule evaluations are checked for the current bar (ndel[cb], rule2[cb],
ruZe3[cb]), and if all evaluations are TRUE, a buy (or a sell, if the short side is
being examined) is generated. Entries are programmed in the standard manner for
each of the three orders tested. Only the in-sample data is used to in the evolu-
tionary process.
The output produced by the shell program permits the selection of desirable
solutions that may be traded on their own or as a group. The solutions may be eas-
ily translated into understandable rules to see if they make sense and to use as ele-
ments in other systems.

Six tests were performed. The evolutionary process was used to evolve optimal
entry rules for the long and short sides with each of the three entry orders: at open,
on stop, and on limit. In all cases, a maximum of 2,500 generations of genetic pro-
cessing was specified. The task of computing all the solutions and saving them to
tiles took only a few hours on a fast Pentium, which demonstrates the practicality
of this technique. For each test, the genetic process produced a tabular file (GFiles
1 through 6) consisting of lines corresponding to each of the generations; i.e., each
line represents a specific solution. Most of the early solutions were close to ran-
dom and not very good, but the quality of the solutions improved as generations
progressed; this is normal for a GA. Each line contains information regarding the
performance of the particular solution that corresponds to the line, as well as to the
complete chromosome, i.e., the set of parameters that represents the gene, which,
in turn, corresponds to the solution expressed in the line.
The best solutions for the long entry at open and for the short entry at open
were selected. These solutions were used to generate the six tests conducted
below. More specifically, the solution that provided the best long entry at open was
tested and its performance was evaluated in the usual way on both samples. The
same solution was also tested and evaluated with entry on stop and on limit. The
same procedure was followed for the short side: The best evolved solution for a

short entry at open was determined. It was then tested on both samples with each
of the other two order types, The optimal solution for each order type was not
selected separately from our genetic runs because doing so would not allow com-
parability across orders. For example, the optimal entry at open might involve a
breakout, while the optimal entry for a stop might involve countertrend momen-
tum-totally different models. By assuming that the entry-at-open model (in
which all trades generated by the model are taken) represents a good, overall
model, the normal course of evaluating that model with the other orders was fol-
lowed. Since the model is kept constant, this approach permits meaningful com-
parisons to be made across orders.

Solutions Evolved for Long Entries
Table 12-I furnishes some of the performance data for the top 20 solutions for
long entries at the open (GFile 1). Each line represents a different trading model.
The parameters are not shown, but the line or generation number (LINE), the
probability or statistical significance (PROB, the decimal point is omitted but
implied in the formatting of these numbers), the average dollars-per-trade
($TRD), the total number of trades taken (TRDS), the profit factor (PFAC™), the
annualized return-on-account (%ROA), and the net profit or loss (NET) in raw
numbers are provided.

The Top 20 Solutions Evolved for Long Entries at the Open
The performance of most of these models is nothing short of impressive. The
better models are statistically significant beyond the 0.00007 level, which means
these solutions have a very high probability of being real and holding up in the
future. Many of the returns were greater than 50% annualized. In some cases, they
reached much higher levels. While the limit order had many of the best solutions,
all orders had many good, if not great, solutions. As in OUT earlier study, the GA
succeeded admirably in finding many tradable models.

Solutions Evolved for Short Entries
Table 12-2 provides a small proportion of GFtile 4, the file for evolved models
generated for short entries at the open. As in Test 1, the top 20 solutions, in terms
of statistical significance or risk-to-reward ratio, are presented. Again, it can be
seen that there were many good solutions. However, they were not as good as
those for the longs. The solutions were not as statistically significant as for the
longs, and the return-on-account numbers were somewhat smaller. A somewhat
more distressing difference is that, in most cases, the number of trades was very
small; the models appear to have been picking rare events. All else aside, the evo-
lutionary process was able to find numerous, profitable rule sets for the short


The Top 20 Solutions Generated for Short Entries at the Open
Test Results for the Standard Portfolio
The best solution shown in Table 12-1 (long trades) and the best solution from
Table 12-2 (short trades) were run with all three entry orders. Tests 1 through 3
represent the best evolved model for long entry at the open tested with entry at
open, on limit, and on stop (respectively). Tests 4 through 6 represent the best
evolved model for short entry over all three orders. Table 12-3 contains the per-
formance data for the best evolved entry-at-open models, both long and short, on
the optimization and verification samples using each of the three entry orders. In
the table, SAMP = whether the test was on the optimization sample (IN or OUT);
ROA% = the annualized return-on-account; ARRR = the annualized risk-to-
reward ratio: PROB = the associated probability or statistical significance; TRDS
= the number of trades taken across all commodities in the portfolio; WZN% = the
percentage of winning trades; $TRD = average profit/loss per trade; BARS = the


Performance of the Best Evolved Entry-at-Open Model on the
$Jeyzation and Verification Samples with Each of the Three Entry

Test 03 Short entry-at-open model, entry on stop
IN / 23.11 0.6oI 0.0311
OUT 1 -13.01 -0.251 0.W 131 30
average number of days a trade was held, NETL = the total net profit on long
trades, in thousands of dollars; and NETS = the total net profit on short trades, in
thousands of dollars.

Tests 1 through 3: Long-Entry-At-Open Model Tested with Entry at Open, on
Limit, and on Stop. As can be seen in Table 12-3, the entry model produced by
the evolutionary process was profitable across all three order types, both in-sam-
ple (as would be expected given the optimization power of GAS) and out-of-sam-
ple. In-sample, no return was less than 42% (annualized) for any order. The
dollars-per-trade figures were all greater than $14,000, and not one system had
less than 60% wins! Out-of-sample, there was more variation. With entry at open
and on limit, performance continued to be stellar, with the average trade above
$10,000 and the return on account above 60%. With a stop order, performance was
not quite as good: The return on account was only 11%, and the average trade
yielded $4,246. The only distressing aspect of the results is the small number of
trades taken. For example, in-sample, with entry at open, there were only 43 trades
taken over a lo-year span on a portfolio of 36 commodities. Out-of-sample, there
were only 17 trades over a 5-year period; the trading frequency was roughly con-
stant at approximately 4 trades per year.
The rules were apparently detecting unusual (but tradable) market events; the
model engaged in what might be termed “rare event trading,” which is not neces-
sarily a bad thing. An assortment of systems, each trading different rare events,
could yield excellent profits. When working with a system such as this, trading a
portfolio of systems, as well as a portfolio of commodities, would be suggested.
In the current situation, however, few trades would place the statistical reliability
of the findings in question. The entire problem can be dealt with by using a some-
what more complex way of handling larger combinations of rules.

Tests 4 through 6: Short-Entry-at-Open Model Tested on Entry at Open, on
Limit, and on Stop. In all cases, the performance of the best evolved short entry
at open model, when tested over the three order types, was poorer on the in-sample
data than the long model. Out-of-sample, the results deteriorated significantly and
losses occurred. Unlike the long model, this one did not hold up. It should be noted,
however, that if both the long and short models had been traded together on out-of-
sample data, the profits from the long side would have vastly outweighed the loss-
es from the short side; i.e., the complete system would have been profitable. The
pattern of longs trading better than shorts is a theme that has been recurrent
throughout the tests in this book. Perhaps the pattern is caused by the presence of
a few markets in the standard portfolio that have been in extreme bullish mode for
a long time. The way commodities markets respond to excess supply, as contrasted
to the way they respond to shortages, may also help explain the tendency.
Market-by-Market Test Results
Table 12-4 contains the market-by-market results for the best evolved entry-at-
open models, both long and short, tested on the optimization and verification
samples using each of the three entry orders. Given the small number of trades
taken, many of the empty cells in this table simply reflect the absence of trades.
The SYM column represents the market being studied. The center and rightmost
columns (CO(/NT) contain the number of profitable tests for a given market. The
numbers in the first row represent test identifiers: 01, 02, and 03 represent tests
with entry at open, on limit, and on stop, respectively, for the long side; 04, 05,
and 06 represent corresponding tests for the short side. The last row (COtrAV™)
contains the number of markets on which a given model was profitable. The data
in this table provides relatively detailed information about which markets are and
are not profitable when traded by each of the models: One dash (-) indicates a
moderate loss per trade, i.e., $2,000 to $4,000; two dashes (--) represent a large
loss per trade, i.e., $4,000 or more; one plus sign (+) means a moderate profit per
trade, i.e., $1,000 to $2,ooO; two pluses (+ +) indicate a large gain per trade, i.e.,
$2,000 or more; and a blank cell means that the loss was between $0 and $1,999
or the profit was between $0 and $1,000 per trade. (For information about the var-
ious markets and their symbols, see Table II-1 in the “Introduction” to Part II.)

Tests 1 through 3: Long-Emiy-at-Open Model Tested on Entry at Open, on Limit,
and on Stop. Table 12-4 indicates that, in-sample, the model was strongly profitable
for the NYFE (but not the S&P X0), the British Pound, the Deutschemark, the
Japanese Yen, Palladium, most of the Wheats, Kansas Wheat, Cocoa, and Lumber,
and Light Crude (if entry at open is omitted). Out-of-sample, the NYFE had no
trades, the British Pound and the Deutschemark continued to be strongly profitable
across all three order types, and many of the other markets in which strong in-sample
profitability was observed had no trades. Out-of-sample, some markets that had not
traded in-sample traded profitably (especially Unleaded Gasoline, Silver, and
Coffee), which indicates that the model continued to perform well, not merely in a
different time period, but on a different set of markets.

Testi 4 through 6: Short-Entry-at-Open Model Tested on Entry at Open, on Limit,
and on Stop. In-sample, the T-Bills, the Deutschema& the Swiss Franc, the
Canadian Dollar, Pork Bellies, Oats, Kansas Wheat, Orange Juice, and Lumber all
showed strong profits. The British Pound and Deutschemark held up out-of-sample.
The Swiss Franc was profitable out-of-sample, hut only with the limit order. It lost
when entry was at open or on stop. The other markets either did not trade out-of-sam-
ple or had losses. Out-of-sample, the NYFE traded strongly profitably across all three
order types, but did not trade profitably in-sample.
Figure 12-1 depicts portfolio equity growth for long trades taken with entry
at open. As is evident, there was a steady, stair-like growth in equity, the stair-like
Breakdown of Performance By Market and Test
Portfolio Equity Growth for Long Model with Entry at the Open

quality resulting from the small number of trades taken. The occasional, strongly
profitable trade caused a sudden step up in equity. The least-squares line fitted to
the equity curve reveals consistent growth in both samples, but slightly greater in
the early years.
The equity growth for the long model with entry on limit, which helps to
control transaction costs, is shown in Figure 12-2. Again, the stair-like growth
in equity is apparent. However, the equity growth was more even; i.e., there was
no slowing down of growth in recent year-in fact, the fitted line is almost
straight. Out-of-sample performance was almost identical to in-sample perfor-
Figure 12-3 shows portfolio equity growth for the best evolved short-entty-
at-open model, evaluated with entry actually at the open. Again, the stair-like
appearance is present. However, except for a strong spurt of growth between
August 1989 and June 1993, the curve is essentially flat. Overall, the equity was
seen rising, except for the flat regions.

Portfolio Equity Growth for Long Model with Entry on a Limit

The Rules for the Solutions Tested

for Long Entry.
Rules The chromosome that represented the best solution for
long entries at the open contained three genes. Each gene was composed of four
numbers and corresponded to a specific rule.
The numbers for Gene 1 were 4, 850,65, and 653, which specified an open-
interest decline rule (case 4), a look-back of 34, and a threshold of 0.042, respec-
tively. The last number (653) was not used or translated because the rule did not
require three blanks to be filled in, only two. If this information is taken and trans-
lated into plain language, the rule says that the open interest must decline at least
4.2% over the past 34 bars for the rule to evaluate as TRUE. In other words, the
open interest 34 bars ago (relative to the current bar) minus the open interest 1 bar
ago, divided by the open interest 34 bars ago, was greater than 0.042.
The numbers for Gene 2 were 1, 256, 530, and 709. The fust number (1)
specified a simple price comparison mle (case I). When the additional numbers
were translated to the correct lookbacks and thresholds, it is apparent that this rule
fires (evaluates as TRUE) when the close 3 days ago is greater than the close 14
days ago plus 3.46 times the average true range.
Porlfolio Equity Growth for Shot-l Model with Entry at the Open

The numbers for Gene 3 were 5, 940, 47, and 610. Rule template 5 (case 5),
which is the open-interest incline rule, was specified by the first number. Fully
instantiating this rule reveals that the rule evaluates as TRUE if the market™s open
interest has risen at least 5.6% in the past 44 days.
If the conditions for all three rules, specified by Genes 1 through 3, were met
on a given bar, a buy signal was generated.
It is interesting that two rules involved open interest, a variable not usually con-
sidered in many popular approaches to trading. It is also noteworthy that the two
open-interest rules, when put together, seem almost contradictory: The current open
interest had to be greater than the open interest 44 bars ago, but less than the open
interest 34 bars ago. The model appears to be somewhat trend-following in that a
recent closing price had to be greater than an older closing price before an entry was
taken. However, time was left for a small pull-back; i.e., the increase in price only had
to be observed 3 bars ago, not in the current bar. The set of rules is not one that would
be easy to discover in a normal manner, without the aid of a genetic algorithm.

Rules for Shorf Enfry. A similar analysis can be done for the shorts as for the
longs. The numbers corresponding to the chromosome that represented the best
solution for short entries at the open were 5, 890, 391, and 532 (Gene 1); 5,705,
760, and 956 (Gene 2); and 10, 163,999, and 196 (Gene 3). When the string of
three genes was translated, it was revealed that two rules deal with open interest
and one with the MACD oscillator. The first open-interest role states that the
open interest 1 bar ago must be at least 38% greater than the open interest 38
bars ago. The second open-interest rule states that the open interest 1 bar ago
must be at least 75% greater than the open interest 25 bars ago. The third rule
states that the slope of the MACD-with a shorter moving average length of 2
and a longer moving average length of 50-must be down, suggesting a current
downward trend. If the conditions for all three rules, specified by the three
genes, were met on a given bar, a sell signal was generated. Again, these rules
would not have been easily discovered when developing a trading model in a
more traditional manner.

As was the case in our earlier study, the use of a GA to select and instantiate rule
templates continued to work well as a means of developing a trading system, or,
at least, an entry model. Results were still impressive, despite such problems as
inadequate numbers of trades in many of the solutions generated. The approach is
certainly one that can serve as the basis for further development efforts. In this
exercise, only a small base of rule templates, involving such fairly simple elements
as price comparisons, moving averages, and indicators, were used. Undoubtedly,
much better results could be obtained by using a more sophisticated and complete
set of role templates as grist for the genetic mill.


. Long positions tend to perform better than short positions for the markets
in our standard portfolio and with the models that were tested. Therefore,
it is probably more worthwhile to place development efforts on a system
that emphasizes the long rather than short side.
. Genetic algorithms appear to be an effective means of discovering small
inefficiencies that are buried in a mountain of efficient market behaviors.
n When used correctly, and in such a manner as discussed above, overopti-
mization (curve-fitting) does not seem to be a serious problem, despite
the optimization power of genetic algorithms. Restrictions on the number
and complexity of the rules in any solution seems to be the key element
in controlling the curve-fitting demon.
. Evolution, as used herein, has the great benefit of producing explicit rules
that can be translated into plain language and understood. Unlike neural
network systems, the trading rules produced by GAS are not hidden in an
inscrutable black box.
. Using genetics in the manner described above has the benefit of produc-
ing a large number of distinct, yet profitable, solutions. It would be easy
evolve and then put together a portfolio of systems.


I n Part II, the focus was on the timing of trade entries. The extent to which various
methodologies are useful in the process of deciding when, where, and how to enter
a trade was examined. Tests were conducted on everything from cycles to sunspot
activity, from simple rule-based approaches to advanced genetic algorithms and
neural networks. In order that a reasonably fair comparison of entry methods could
be made, the exit strategy was intentionally kept simple and constant across all
tests. A fixed money management stop, a profit target limit, and an exit at market
after a given number of bars, or days, in the trade were used. In Part III, attention
will be shifted to the problem of how to get out of a trade once in, i.e., to exit strate-
gies, an issue that has often been neglected in the trading literature.

In many ways, a good exit is more critical and difficult to achieve than a good entry.
The big difference is that while waiting for a good opportunity to enter a trade, there
is no market risk. If one opportunity to enter is missed, another will always come
along-and a good, active trading model should provide many such opportunities.
When a trade is entered, however, exposure to market risk occurs simultaneously.
Failing to exit at an appropriate moment can cost dearly and even lead to the dread-
ed margin call! We actually know someone who made a quick, small fortune trad-
ing, only to lose it all (and then some) because the exit strategy failed to include a
good money management stop! To get out of a trade that has gone bad, it is not a
good idea to simply wait for the next entry opportunity to come along. Similarly,
erring on the side of safety and exiting at the drop of a hat can also drain a trading

account, albeit less dramatically through slow attrition. The problem with frequent
and hasty exits is that many small losses will occur due to the sacrifice of many
potentially profitable trades, and trades that are profitable will be cut short before
reaching their full profit potential. A good exit strategy must, above all, strictly con-
trol losses, but it must not sacrifice too many potentially profitable trades in the
process; i.e., it should allow profitable trades to fully mature.
How important is the exit strategy? If risk can be tightly controlled by quick-
ly bailing from losing trades, and done in such a way that most winning trades am
not killed or cut short, it is possible to turn a losing system into a profitable one!
It has been said that if losses are cut short, profits will come. A solid exit strategy
can, make a profitable system even more lucrative, while reducing equity volatili-
ty and drawdown. Most importantly, during those inevitable bad periods, a good
exit strategy that incorporates solid money management and capital preservation
techniques can increase the probability that the trader will still be around for the
next potentially profitable trade.

There am two goals that a good exit strategy attempts to achieve. The first and
most important goal is to strictly control losses. The exit strategy must dictate how
and when to get out of a trade that has gone wrong so that a significant erosion of
trading capital can be prevented. This goal is often referred to as money manage-
ment and is frequently implemented using stop-loss orders (money management
stops). The second goal of a good exit strategy is to ride a profitable trade to full
maturity. The exit strategy should determine not only when to get out with a loss,
but also when and where to get out with a profit. It is generally not desirable to
exit a trade prematurely, taking only a small profit out of the market. If a trade is
going favorably, it should be ridden as long as possible and for as much profit as
reasonably possible. This is especially important if the system does not allow mul-
tiple reentries into persistent trends. “The trend is your friend,” and if a strong
trend to can be ridden to maturity, the substantial profits that will result can more
than compensate for many small losses. The protit-taking exit is often implement-
ed with trailing stops. profit targets, and time- or volatility-triggered market
orders. A complete exit strategy makes coordinated use of a variety of exit types
to achieve the goals of effective money management and profit taking.

There are a wide variety of exit types to choose from when developing an exit
strategy. In the standard exit strategy, only three kinds of exits were used in a sim-
ple, constant manner. A fixed money management exit was implemented using a
stop order: If the market moved against the trade more than a specified amount.
the position would be stopped out with a limited loss. A p&It rarget exit was
implemented using a limit order: As soon as the market moved a specified amount
in favor of the trade, the limit would be hit and an exit would occur with a known
profit. The time-based exir was such that, regardless of whether the trade was prof-
itable, if it lasted more than a specified number of bars or days, it was closed out
with an at-the-market order.
There are a number of other exit types not used in tbe standard exit strategy:
trailing exits, critical threshold exits, volatility exits, and signal exits. A trailing
exit, usually implemented with a stop order and, therefore, often called a trail-
ing “top, may be employed when the market is moving in favor of the trade. This
stop is moved up, or down, along with the market to lock in some of the paper
profits in the event that the market changes direction. If the market turns against
the trade, the trailing stop is hit and the trade is closed out with a proportion of
the profit intact. A critical threshold exit terminates the trade when the market
approaches or crosses a theoretical barrier (e.g., a trendline, a support or resis-
tance level, a Fibonacci retracement, or a Gann line), beyond which a change in
the interpretation of current market action is required. Critical threshold exits
may be implemented using stop or limit orders depending on whether the trade
is long or short and whether current prices are above or below the barrier level.
If market volatility or risk suddenly increases (e.g., as in the case of a “blow-off
top), it may be wise to close out a position on a volatility exit. Finally, a signal
exit is simply based on an expected reversal of market direction: If a long posi-
tion is closed out because a system now gives a signal to go short, or because an
indicator suggests a turning point is imminent, a signal exit has been taken.
Many exits based on pattern recognition are signal exits.

Money Management Exits
Every exit strategy must include a money management exit. A money management
exit is generally implemented using a stop order. Therefore, it is often referred to
as a money management stop. Such a stop closes out a trade at a specified amount
of adverse excursion (movement against the trade), or at a specified price below
(if long) or above (if short) the price at which the trade was entered. A money man-
agement stop generally stays in place for the duration of the trade. Its purpose is
to control the maximum risk considered tolerable. Of course, the potential risk
may be greater than what was expected. The market could go limit up (or down)
or have a large overnight gap. Trading without a money management stop is like
flying in a rickety old plane without a parachute,
The issue is not whether a money management stop should be used. Rather,
it is determining the optimal placement of the stop. There are many ways to decide
where to place money management stops, The simplest placement occurs by
assessing the maximum amount of money that can be risked on a given trade. For
example, if a trade on the S&P 500 is entered and the trader is not be willing to
risk more than $1,500, a money management stop that uses a $1,500 stop-loss
order would be specified. If the market moves against the trade more than $1,500
(three S&P points), the stop gets hit and the position is closed out. Another way to
set the money management stop is on the basis of volatility. In volatile markets and
periods, it may be a good idea to give trades more room to breathe, i.e., to avoid
having the stop so close to the market that potentially profitable trades get stopped
out with losses.
A good way to set a money management stop is on the basis, of a price bar-
rier, such as a trendline or support/resistance level. In such cases, the stop also
serves as a critical threshold exit. For example, if there are a number of trend and
support lines around 936.00 on the S&P 500, and a long position at 937.00 has just
been entered, it might be worth considering the placement of a stop a little below
936.00, e.g., at 935.50. Setting a protective stop at 935 is logical since a break
through support suggests that the trend has changed and that it is no longer smart
to be long the S&P 500. In this example, only $750 is at risk, substantially less
than the $1,500 risked when using the money management stop that was based on
a dollar amount. A tighter stop can often be set using a barrier or critical price
model than would be the case using a simple dollar-amount model.
As hinted above, setting a money management stop involves a compromise. It
is good to have a very tight stop, since losing trades then involve only tiny, relatively
painless losses. However, as the stop is righrened (i.e., moved closer to the entry or
current price), the likelihood of it getting triggered increases, even if the market even-
tually moves in favor of the trade. For example, if a $50 stop loss is set, almost all
trades on the S&P 500, regardless of entry method, will be stopped out with small
losses. As a stop gets tighter, the percentage of winning trades will decrease. The stop
eventually ends up sacrificing most of what would have been profitable trades. On the
other hand, if the stop is too loose, although the winning trades are retained, the
adverse excursion on those winners, and the losses on the losing trades, will quickly
become intolerable. The secret is to find a stop that effectively controls losses with
out sacrificing too many of the trades that provide profits.

Trailing Exits
A rrailing exit is usually implemented with a so-called trailing stop. The purpose
behind this kind of exit is to lock in some of the profits, or to provide protection
with a stop that is tighter than the original money management stop, once the mar-
ket begins to move in the trade™s favor. If a long position in the S&P 500 is taken
and a paper profit ensues, would it not be desirable to preserve some of that prof-
it in case the market reverses? This is when a trailing stop comes in useful. If a
$1,500 money management stop is in place and the market moves more than
$1,500 against the trade, the position is closed with a $1,500 loss. However, if the
market moves $1,000 in the trade™s favor, it might be wise to move the old money
management stop closer to the market™s current price, perhaps to $500 above the
current market price. Now, if the market reverses and the stop gets hit, the trade
will be closed out with a $500 profit, rather than a $1,500 loss! As the market
moves further in favor of the trade, the trailing stop can be moved up (or down, if
in a short position), which is why it is called a trailing stop, i.e., it is racheted up
(or down), trailing the market-locking in more of the increasing paper profit.
Once it is in place, a good trailing stop can serve both as an adaptive money
management exit and as a profit-taking exit, all in one! As an overall exit strategy,
it is not bad by any means. Trailing stops and money management stops work hand
in hand. Good traders often use both, starting with a money management stop, and
then moving that stop along with the market once profits develop, converting it to
a trailing stop. Do not be concerned about driving the broker crazy by frequently
moving stops around to make them trail the market. If trading is frequent enough
to keep commissions coming in, the broker should not care very much about a few
adjustments to stop orders. In fact, a smart broker will be pleased, realizing that
his or her client is much more likely to survive as an active, commission-produc-
ing trader, if money management and trailing stop exits are used effectively.
How is the placement of a trailing stop determined? Many of the same prin-
ciples discussed with regard to money management exits and stops also apply to
trailing exits and stops. The stop can be set to trail, by a fixed dollar amount, the
highest (or lowest, if short) market price achieved during the trade. The stop can
be based on a volatility-scaled deviation. A moving threshold or barrier, such as a
trend or Gann line, can be used if there is one present in a region close enough to
the current market action. Fixed barriers, like support/resistance levels, can also be
used: The stop would be jumped from barrier to harrier as the market moves in the
trade™s favor, always keeping the stop comfortably trailing the market action.

Profit Target Exits
A projit target exit is usually implemented with a limit order placed to close out a
position when the market has moved a specified amount in favor of the trade. A
limit order that implements a profit target exit can either be fixed, like a money
management stop, or be moved around as a trade progresses, as with a trailing
stop. A fixed profit target can be based on either volatility or a simple dollar
amount. For example, if a profit target of $500 is set on a long trade on the S&P
500, a sell-at-limit order has been placed: If the market moves $500 in the trade™s
favor, the position is immediately closed. In this way, a quick profit may be had.
There are advantages and disadvantages to using a profit target exit. One
advantage is that, with profit target exits, a high percentage of winning trades can
be achieved while slippage is eliminated, or even made to work in the trader™s
favor. The main drawback of a profit target exit is that it can cause the trader to
prematurely exit from large, sustained moves, with only small profits, especially
if the entry methods do not provide for multiple reentries into ongoing trends. All
things being equal, the closer the profit target is to the entry price, the greater the
chances are of it getting hit and, consequently, the higher the percentage of win-
ning trades. However, the closer the profit target, the smaller the per-trade profit.
For instance, if a $50 profit target is set on a trade in the S&P 500 and the money
management stop is kept far out (e.g., at $5,000), more than 95% of the trades will
be winners! Under such circumstances, however, the wins will yield small profits
that Will certainly be wiped out, along with a chunk of principal, by the rare $5,000
loss, as well as by the commissions. On the other hand, if the profit target is very
wide, it will only occasionally be triggered, but when it does get hit, the profits
will be substantial. As with exits that employ stops, there is a compromise to be
made: The profit target must be placed close enough so that there can be benefit
from an increased percentage of winning trades and a reduction in slippage, but it
should not be so close that the per-trade profit becomes unreasonably small. An
exit strategy does not necessarily need to include a profit target exit. Some of the
other strategies, like a trailing stop, can also serve to terminate trades profitably.
They have the added benefit that if a significant trend develops, it can be ridden to
maturity for a very substantial return on investment. Under the same conditions,
but using a profit target exit, the trade would probably be closed out a long time
before the trend matures and, consequently, without capturing the bulk of the prof-
it inherent in the move.
Personally, we prefer systems that have a high percentage of winning trades.
Profit targets can increase the percentage of wins. If a model that is able to reen-
ter active trends is used, profit target exits may be effective. The advantages and
disadvantages really depend on the nature of the system being trading, as well as
on personal factors.
One kind of profit target we have experimented with, designed to close out
dead, languishing trades that fail to trigger other types of exits, might be called a
shn™nking target. A profit target that is very far away from the market is set.
Initially, it is unlikely to be triggered, but it is constantly moved closer and closer
to where the market is at any point in the trade. As the trade matures, despite the
fact that it is not going anywhere, it may be possible to exit with a small profit
when the profit target comes into a region where the market has enough volatility
to hit it, resulting in an exit at a good price and without slippage.

Time-Based Exits
Time-based exits involve getting out of the market on a market order after having
held a trade for a fixed period of time. The assumption is that if the market has not,
in the specified period of time, moved sufficiently to trigger a profit target or some
other kind of exit, then the trade is probably dead and just tying up margin. Since
the reason for having entered the trade in the first place may no longer be relevant,
the trade should be closed out and the next opportunity pursued.

Volatility Exits
A volatility exit depends on recognizing that the level of risk is increasing due to
rapidly rising market volatility, actual or potential. Under such circumstances, it is
prudent to close out positions and, in so doing, limit exposure. For instance, when
volatility suddenly expands on high volume after a sustained trend, a “blow-off
top might be developing. Why not sell off long positions into the buying frenzy?
Not only may a sudden retracement be avoided, but the fills are likely to be very
good, with slippage working with, rather than against, the trader! Another volatil-
ity exit point could be a date that suggests a high degree of risk, e.g., anniversaries
of major market crashes: If long positions are exited and the market trends up
instead, it is still possible to jump back in. However, if a deep downturn does
occur, the long position can be reentered at a much better price!
What else constitutes a point of increased risk? If an indicator suggests that
a trend is about to reverse, it may be wise to exit and avoid the potential reversal.
If a breakout system causes a long entry into the S&P 500 to occur several days
before the full moon, but lunar studies have shown that the market often drops
when the moon is full and the trade is still being held, then it might be a good idea
to close the position, thus avoiding potential volatility. Also remember, positions
need not be exited all at once. Just a proportion of a multicontract position can be
closed out, a strategy that is likely to help smooth out a trader™s equity curve.

Barrier Exits
A barrier exit is taken when the market touches or penetrates some barrier, such as a
point of support or resistance, a trendline, or a Fibonacci retracement level. Barrier
exits are the best exits: They represent theoretical barriers beyond which interpretation
of market action must be revised, and they often allow very close stops to be set, there-
by dramatically reducing losses on trades that go wrong. The trick is to find a good
barrier in approximately the right place. For example, a money management stop can
serve as a barrier exit when it is placed at a strong support or resistance level, if such
a level exists close enough to the entry price to keep potential loss within an accept-
able level. The trailing exit also can be a barrier exit if it is based on a trendhne.

Signal Exits
Signal exits occur when a system gives a signal (or indication) that is contrary to
a currently held position and the position is closed for that reason. The system gen-
erating the signal need not be the same one that produced the signal that initiated

the trade. In fact, the system does not have to be as reliable as the one used for
trade entry! Entries should be conservative. Only the best opportunities should be
selected, even if that means missing many potential entry points, Exits, on the
other hand, can be liberal. It is important to avoid missing any reversal, even at the
expense of a higher rate of false alarms. A missed entry is just one missed oppor-
tunity out of many. A missed exit, however, could easily lead to a downsized
account! Exits based on pattern recognition, moving average crossovers, and
divergences are signal exits.

There are a number of issues to take into account when attempting to exit the mar
ket. Some orders, such as stops, may result in poor executions and substantial
transaction costs due to such factors as “gunning” and slippage. Other orders, such
as limits, may simply not be filled at all. There are also trade-offs to consider; e.g.,
tight stops might keep losses small but, at the same time, kill potentially winning
trades and increase the number of losses, Loose stops allow winning trades to
develop, but they do so at the cost of less frequent, but potentially catastrophic,
losses. In short, there are aspects to exiting that involve how the orders are placed
and how the markets respond to them.

Sometimes putting stops in the market as they really are may not be prudent, espe-
cially when tight stops are being used Floor traders may try to gun the stops to pick
up a few ticks for themselves. In other words, the floor traders may intentionally try
to force the market to hit the stops, causing them to be executed. When stops are taken
out this way, the trader who placed them usually ends up losing. How can this be
avoided? Place a catastrophe stop with the broker, just in case trading action cannot
be taken quickly enough due to busy phones or difficult market conditions. The cat-
astrophe stop is placed far enough away from the market that it is beyond the reach
of gunning and similar “mischief.” No one would like to see this stop hit, but at least
it will keep the trader from getting killed should something go badly wrong. The real
stop should reside only with the trader, i.e., in the system on the computer: when this
stop gets hit, the computer displays a message and beeps, at which time the broker
can be immediately phoned and the trade exited. Handled this way, tight stops can be
used safely and without the risk of being gunned.

Trade-Offs with Protective Stops
Usually, as stops are moved in tighter, risk control gets better, but many winning
trades could be sacrificed, resulting in the decline of profit, Everyone would love
to use $100 stops in the S&P 500 because the losses on losing trades would be fair-
ly small. However, most systems would lose 95% of tbe time! Certain systems
allow stops to be tight, just because of the way the market moves relative to the
entry point. Such systems yield a reasonable percentage of winning trades. When
developing systems, it is good to build in a tight stop tolerance property. Such sys-
tems are often based on support and resistance or other barrier-related models.
Many systems do not have a tight stop characteristic and so require wider stops.
Nevertheless, there is always a trade-off between having tight stops to control risk,
but not so tight that many winning trades are sacrificed. Loose stops will not sac-
rifice winning trades, but the bad trades may run away and be devastating. A com-
promise must be found that, in part, depends on the nature of the trading system
and the market being traded.

Slippage is the amount the market moves from the instant the trading order is
placed or, in the case of a stop, triggered, to the instant that order gets executed.
Such movement translates into dollars. When considered in terms of stops, if the
market is moving against the trade, the speed at which it is moving affects the
amount that will be lost due to slippage. If the market is moving quickly and a
stop gets hit, a greater loss due to slippage is going to be experienced than if the
market was moving more slowly. If there was a stop loss on the S&P 500 of $500
and the market really started moving rapidly against the trade, $200 or $300 of
slippage could easily occur, resulting in a $700 or $800 loss, instead of the $500
loss that was anticipated. If the market is moving more slowly, then the slippage
might only be $25 or $50, resulting in a $525 or $550 loss. Slippage exists in all
trades that involve market or stop orders, although it may, in some circumstances,
work for rather than against the trader. Limit orders (e.g., “sell at $2 or better”)
are not subject to slippage, but such orders cannot close out a™position in an

Contrarian Trading
If possible, exit long trades when most traders are buying, and exit short trades
when they are selling. Such behavior will make it easier to quickly close out a
trade, and to do so at an excellent price, with slippage working for rather than
against the trader. Profit targets usually exit into liquidity in the sense just dis-
cussed. Certain volatility exits also achieve an exit into liquidity. Selling at a blow-
off top, for example, is selling into a buying frenzy! “Buy the rumor, sell the news”
also suggests the benefits of selling when everyone starts buying. Of course, not
all the exits in an exit strategy can be of a kind that takes advantage of exiting
into liquidity.
A complete exit strategy makes coordinated, simultaneous use of a variety of exit
types to achieve the goals of effective money management and profit taking. Every
trader must employ some kind of catastrophe and money management stop. It is also
advisable to use a trailing stop to lock in profits when the market is moving in the
trade™s favor. A risk- or volatility-based exit is useful for closing positions before a
stop gets hit-getting out with the market still moving in a favorable direction, or at
least not against the trade, means getting out quickly and with less slippage.

In the next few chapters, a variety of exit strategies are tested. In contrast to entries,
where an individual entry could be tested on its own, exits need company. An entire
exit strategy must be tested even if, for purposes of scientific study, only one element
at a time is altered to explore the effects. The reason for this involves the fact that an
exit must be achieved in some fashion to complete a trade. If an entry is not signaled
now, one will always come along later. This is not so with an exit, where exposure to
market risk can become unlimited over time, should one not be signaled. Consider,
for example, a money management stop with no other exit. Are looser stops, or per-
haps the absence of any money management stop, better than tight ones? The first test
determines the consequences of using a very loose stop. If the no-stop condition was
the first tested, there would be no trades to use to evaluate money management stops;
i.e., there would only be an entry to a trade from which an exit would never occur.
With a loose stop, if the market goes in favor of the trade, perhaps the trade would be
held for years or never exited, leading to the same problem as the no-stop condition.
These examples illustrate why exits must be tested as parts of complete, even if sim-
ple, strategies, e.g., a stop combined with a time limit exit.
For the aforementioned reasons, all the tests conducted in Chapter 13 employ a
basic exit strategy, specifically, the standard exit strategy (and a modification thereon
used throughout the study of entries; this will provide a kind of baseline. In Chapters
14 and 1.5, several significant variations on, and additions too, the standard exit will
be. tested. More effective stops and profit targets, which attempt to lock in profit with-
out cutting it short, are examined in Chapter 14. In Chapter 15, techniques developed
in the section on entries are brought into the standard exit strategy as additional com-
ponents, specifically, as signal exits. Moreover, an attempt will be made to evolve
some of the elements in the exit stmtegy. To test these various exit strategies in a man
ner that allows comparisons to be made, a set of standard entry models is needed.

When studying entries, it was necessary to employ a standard, consistent exit
methodology. Likewise, the investigation of exits requires the use of a standard
entry method, a rather shocking one, i.e., the random entry model. It works this
way: The market is entered at random times and in random directions. As in all
previous chapters, the number of contracts bought or sold on any entry is selected
to create a trade that has an effective dollar volatility equal to two contracts of the
S&P 500 at the end of 1998. Due to the need to avoid ambiguity when carrying
out simulations using end-of-day data, the entries used in the tests of the various
exit strategies are restricted to the open. If entry takes place only at the open, it
will be possible to achieve unambiguous simulations with exits that take place on
intrabar limits and stops. Unambiguous simulations involving such orders would
otherwise not be possible without using tick-by-tick data. As previously, the stan-
dard portfolio and test platform will be used.

The Random Entry Model
To obtain the random entries, a pseudo-random number generator (RNG) is used
to determine both when the trades are entered and whether those trades are long
or short. This approach is being taken for a number of reasons. First of all, a uni-
form way of testing exits is needed. Different types of entry systems have their
own unique characteristics that affect the ways in which different exits and/or
stops behave. For example, if an entry system forecasts exact market turning
points, a very tight money management stop can be used that might even improve
the system. However, with more typical entries, that might not be the case.
Therefore, it is preferable to take the kinds of entries that might be typical of a bad
system, or a system that is slightly tradable but not very good, to see how much
improvement can be had by use of a good exit. Obviously, a great entry system
makes everything easier and reduces the need to find perfect exits. An entry sys-
tem that stays fixed over the exploration of the different types of exits allows deter-
mination of the degree to which profitability can be improved (or losses reduced)
by effective money management and exit strategies,
Second, random entries help ensure that the system contains a number of bad
trades, which are needed to test the mettle of any exit strategy. After all, the whole
idea of a good exit strategy is to cut all the bad trades quickly before they do dam-
age and to preserve and grow the good trades. With a really good exit strategy, it
is reasonable to assume that bad trades will be exited before large losses are
incurred and that profit will be made from the good trades. This relates to the pop-
ular notion that if losses are cut short, the profits will come, regardless of the sys-
tem. The studies that follow put the truth of this axiom to the test.
Last, the approach provides an entry model that has a reasonably large, fixed
number of trades. The sample consists of all kinds of trades, many bad ones and
some good ones (by accident or chance). Under such circumstances, the overall
performance of the system is expected to be due exclusively to the exits.
Generating the Random Entries. The random entry model generates a long
series of numbers (composed of + Is, -Is, and OS), each of which corresponds to

a trading day. The numbers represent whether, for any given date, a long entry sig-
nal (+ l), a short entry signal (-I), or no entry signal at all (0) should be generated.
For example, the random entry system might generate a -1 on October 29, 1997,
which means that there is a signal to enter a short trade at the open on that date.
The RNG used to implement the random entry strategy is the one described
as ran2 in Numerical Recipes in C (Press et al., 1992). The period of this RNG is
greater than 2 multiplied by 10”. It is by far a better RNG than those normally
found in the run-time libraries that usually come with a programming language.
Signals are generated based on random numbers from this generator. On each bar,
a uniformly distributed random number between 0 and 1 is obtained from the
RNG. If the random number is less than 0.025, a short signal is generated. The
probability of a short being generated on any bar is 0.025; i.e., a short signal
should occur every 40 bars, on average. If the random number is greater than
0.975, a long signal is issued; these signals also should occur, on average, every
40 bars. In other words, on average, a long or a short trading signal should occur
every 20 bars. The limit and stop prices are calculated in the usual way. Orders are
placed in the usual manner.

The Standard Exit Strategy

The standard exit strategy (SES) was used throughout the tests of entry methods.
Basically, the SES employs a money management stop, a profit target limit, and a
market order for exit after a specified amount of time. The examination of this
strategy provides a baseline against which variations and more complex exit
strategies (studied in the next two chapters) may be judged. The SES is being
investigated using the random entry technique discussed in the “Introduction” to
Part III.

Although the standard exit strategy is basic and minimal, it does incorporate ele-
ments that are essential to any exit strategy: profit taking, risk control, and time
exposure restraint. The profit-taking aspect of the SES is done through a profit tar-
get limit order that closes out a trade when it has become sufficiently profitable.
Tbe risk control aspect of the SES is accomplished using a simple money man-
agement stop that serves to close out a losing position with a manageable loss. The
time exposure restraint is achieved with a market order, posted after a certain
amount of time has elapsed. It closes out a languishing trade that has hit neither
the money management stop nor the profit target.

The standard exit was intended to be simply a minimal exit for use when testing
various entry strategies. As such it is not necessarily a very good exit. Unlike an
optimal exit strategy, the standard exit is unable to hold onto sustained trends and

ride them to the end. In addition, a profit can be developed and then lost. The rea-
son is that the SES has no way of locking in any proportion of paper profit that
may develop. A good exit strategy would, almost certainly, have some method of
doing this. After having made a substantial paper profit, who would want to find
it quickly vanish as the market reverses its course? The fixed time limit also con-
tributes to the inability of the SES to hold onto long, sustained moves, but it was
a desirable feature when testing entry strategies. Finally, the SES lacks any means
of attempting to exit a languishing trade at the best possible price, as might be
done, e.g., by using a shrinking profit target.
On the positive side, the SES does have the basics required of any exit strate-
gy. Through its money management stop, the SES has a means of getting out of a
bad trade with a limited loss. The limit order or profit target allows the SES to close
a trade that turned substantially profitable. Using the time limit exit, the SES can exit
a trade that simply does not move. These three features make the standard exit def-
initely better than a random exit or a simple exit after a fixed number of bars.

A major reason for testing the SES is to be able to make comparisons between it
and the other exit strategies that will be tested. The SES will serve as a good pivot
point or baseline, having been used in the study of entries. An additional benefit
that is quite important and useful is derived from these tests. The SES will be test-
ed with a random en@, providing a random entry baseline against which the var-
ious real entries (tested in Part II) may be compared. The tests in this chapter,
therefore, provide baselines for both the previous chapters and those that follow.
An additional reason for doing these tests is to determine how much was lost by
restricting the SES to the close in earlier tests. In some of the tests below, the
restriction to the close will be lifted, an action that should improve the overall per-
formance of the SES.
Four tests will be conducted. The first three tests examine the SES in the
form that was used in all the earlier chapters; i.e., entries will be taken at the open,
on a stop, or on a limit, and exits will take place only on the close. The remaining
test will study the SES in a way that permits stop and limit exits to take place
inside the bar, lifting the restriction of the exit to the close; the entry in this test
will only take place on the open, to avoid the kinds of ambiguity mentioned in the
previous chapter.

To test the original SE& the random entry method is used (described in the
“Introduction” to Part III). The exits are the usual standard exits (with exit restricted
on the close) that were used throughout the study of entries. The rules for the SES
are as follows: If, at the close, the market is more than some multiple (the money
management stop parameter) of the 50-bar average true range below the entry price,
then exit; this is the money management stop. If the price at the close is greater than
some other multiple (the profit tzuget limit parameter) of the same average true range
above the entry price, then exit; this is the profit target limit. These rules are for long
positions, and the exit is restricted to the close. For short positions, the placement of
the thresholds are reversed, with the money management exit placed above the entry
price and the profit target exit placed below. If, after 10 days, neither the money
management stop nor profit target limit has been hit, close out the trade with a mar-
ket-at-close order. The code that follows implements these rules, as well as the ran-
dom entry. There are three tests, one for each type of entry order (at open, on limit,
and on stop). The standard software test platform and portfolio are used.

s t a t i c void Model (float *parms, float ˜dt, float *op. float *hi,
float *lo. float *cls. float *vol. float *oi, float *dlrv, int nb,
TRDSIM 6rts. float *eqclsl {

,, Implements the random encry model with the Standard exit
I/ File = xl9modOl.c
vector [I. .MAxPRMl Of parameters
// pa=ms
vector ,l..rlb, Of dates i n YYMMDD form
/I dt
vector Cl. .nbl of opening prices
// oPn
vector [I. .nbl of high prices
// hi
vector [I. .“bl Of low prices
// 10
vector [I. .nbl of closing prices
// ClS
YeCtor L1. .nbl O f “Ol”mes
// vo1
vector Il..nbl Of open interest numbers
// oi
,, dlrv vector Ll..nbl of average dollar volatilities
number Of bars in data series or vectors
I/ nb
Erading siln”latOl class i n s t a n c e
// ts
vector [I..*1 of closing equity levels
// eqc1s
// declare local scratch variables
static int rc, c b , ncontracts, maxhold. ordertype, signal;
s t a t i c f l o a t mmstp, ptlim, stpprice, limprice, tmp;
s t a t i c float eritatrbmxBAR+1,, mum;
static int ranseed;
static long iseed;

// copy parameters to local variables for clearer reference
ranseed = parms˜81; ,, used t o select random seed
ordertype = parmsL91; // e n t r y : kopen, 2dimit. 3=stop
maxhold = 10; ,, maximum holding period

// perform whole-series calculations
A”gTr”eRangeS(exitatr,hi,lo,cls,50,nb); ,, ATR for exit
case 2: tS.buylimitc™2™, limprice, *contracts,; break;
case 3: ts.buystop˜˜3™. stpprice, ncontractsl; break;
default: nrerrOr˜˜I*“alid buy order selected”);
e l s e if˜ts.positionO >= 0 && s i g n a l = = -1) (
switch(ordertype) ( I/ select desired order type
case 1: ts.sellopen˜˜4™, ncontractsl; break;
case 2 : ts.selllimitl˜S™, limprice, ncontracts); b r e a k ;
case 3: t?..6e11*tOp˜˜6™, stpprice, ncontracts˜; break;
default: nrerror˜“lnvalid sell order selected”);

// instruct simulator to employ standard exit strategy
tmp = exitatrLcb1 ;
ts. Sb3exitC1s C˜X™ , ptlim*tmp, mmstp*tmp. maxholdh

) ,, process next bar

The code is similar to that presented in earlier chapters. Only the generation
of the entry signals has changed. Entry signals are now issued using a pseudo-ran-
dom number generator (RNG). Before entering the loop that steps through bars to
simulate the process of trading, the RNG is initialized with a unique seed. The ini-
tialization seed is determined by the market number and by a parameter (ranseed).
By changing the parameter, a totally different sequence of random entries is gen-
erated. The exact seed values are irrelevant in that, for every seed, a unique series
will be generated because the period of the RNG is extremely large.
The RNG used is the one described as ran2 in Numen™cal Recipes in C (Press
et al., 1992). The period of this RNG is greater than 2 multiplied by 10™“. This
RNG is by far better than those that normally come as part of a programming lan-
guage library. Inside the loop, where trading actually takes place, signals are gen-
erated based on random numbers. The steps are very simple. On each bar, a
uniformly distributed random number between 0 and 1 is obtained from the RNG.
If the random number is less than 0.025, a short signal is generated. The proba-
bility of a short being generated on any bar is 0.025; i.e., a short signal should
occur every 40 bars, on average. If the random number is greater than 0.975, a long
signal is issued, these signals should also occur, on average, every 40 bars. In other
words, on average, a long or a short trading signal should occur every 20 bars. The
limit and stop prices are calculated in the usual way. Orders are placed and exits
specified in the usual manner.
The steps that are used to conduct each of the three tests are as follows: On
the in-sample data and for each entry order type, 10 distinct series of random
entries are generated and traded. The best of those sequences are then examined
on the verification or out-of-sample data. The process mimics that of optimizing a
parameter in a real system by stepping it from, e.g., 1 to 10; here the parameter
simply selects a totally different series of random entries for each value.

Test Results
Tables 13-1, 13-2, and 13-3 present the portfolio performance that resulted from
trading random entries with the standard exit strategy. Each of the numbers in the
column RAND represents a seed modifier (ranseed) that causes the RNG to gen-
erate a different sequence of random entries. NET = the total net profit, in thou-
sands of dollars. NETL = the total net profit for the longs. NETS = the total net
profit for the shorts, PFAC = the profit factor. ROA% = the annualized return on
account. ARRR = the annualized risk-reward ratio. PROB = the statistical signif-
icance or probability, DRAW = the drawdown, in thousands of dollars. TRDS =
the number of trades. WIN% = the percentage of wins. AVTR = the average trade,
in dollars. TRDB = the average bars per trade, rounded to the nearest integer. VER
zz the performance for the random sequence that provided the best in-sample per-
formance when this sequence is continued and then tested on the verification sam-
ple. AVG = the average in-sample value of the numbers in rows 1 through 10.
STDEV = the standard deviation for the in-sample performance data shown in
rows 1 through 10.

Test I: SES with Random Entries at the Open. This system did not perform very
well in-sample. The average trade, over all 10 randomizations, lost $2,243, with a


Results for the Standard Exit with Random Entries at the Open
TABLE 13-2

Results for the Standard Exit with Random Entries on a Limit

TABLE 13-3

Results for the Standard Exit with Random Entries on a Stop

standard deviation of $304. In terms of average dollars-per-trade. the less attractive
systems that were tested when studying entries were on par with the results for the
current system. In fact, some of them performed significantly worse than chance.
The percentage of wins was very stable, with the average at 36.91% and a standard
deviation of only 0.7%. The total number of trades taken per commodity, over the
lo-year in-sample period, was 3,703, about the number it should be, given the prob-
ability of taking a random entry on any bar.

Out-of-sample, performance was within the expected range, consistent with
in-sample performance. The percentage of wins was 37%, very close to that for in-
sample results. The average loss per trade was $1,883, which is within 1 standard
deviation of the in-sample estimate. Obviously, the standard exit was unable to
pull a profit out of trades entered randomly.

Test 2: SES with Random Entries on Limit. Table 13-Z is identical to Table 13-
1, except that it shows portfolio behavior for the standard exit with random entries
taken on a limit order. In-sample, the average loss per trade of $1,930 was some-
what less, demonstrating the effect of the limit order in reducing transaction costs.
The standard deviation was somewhat higher: $477. The percentage of winning
trades (38.73%) was just under 2% better, due to the better prices achieved with a
limit entry. As was anticipated, other than such small changes as those described,
nothing else in Table 13-Z is of any great interest.
Out-of-sample, the system lost $3,056 per trade, just over 2 standard deviations
worse than in-sample behavior. For whatever reason, the limit order may have had
some real effect with random entries, making the system perform more poorly in
recent yearn. The percentage of wins was also slightly worse, i.e., 37%, just under 2
standard deviations below in-sample behavior, but on par with entty at the open.

Test 3: SES with Random Enhies on Stop. Table 13-3 contains information
about the portfolio behavior for the standard exit when trades were entered ran-
domly on a stop. In terms of dollars-per-trade, in-sample performance was
between that of the other two orders, with a loss per trade of $2,039. The standard
deviation was $391. The percentage of wins was lower, 36.36%, with a standard
deviation of 1.12%. The lower percentage of wins probably reflects the poorer
entry prices achieved using the stop.
Out-of-sample, the average trade and percentage of wins were within 2 Stan-
dard deviations plus or minus the in-sample figures, demonstrating that out-of-
sample performance was within the statistically expected range and fundamentally
no different from in-sample performance.
The performance figures in Tables 13-l through 13-3 provide a baseline (in
the form of means and standard deviations) that can serve as a yardstick when
evaluating ,the entries studied in Part Il of this book. For this purpose the $TRD
and WIN% figures are the best ones to use since they are not influenced by the
number of trades taken by a system.

Market-by-Market Performance for SES with Random Entries at Open, In
Table 13-4, the behavior of the standard exit with random entries taken at the open
is broken down by market and by sample. The particular randomization used was
the one that produced the best in-sample performance (in terms of annualized risk-
to-reward ratio) in Test 1. The leftmost column (SYM) contains the commodity

TABLE 13-4

Market-by-Market Results for the Standard Exit with Random Entries
at the Open

symbol. The remaining columns contain information about various aspects of per-
formance, both in-sample and out-of-sample. NETL and NETS are the net profits
for long and short positions (respectively), in thousands of dollars. ROA% = the
annualized return-on-account. AVTR = the average dollars profit or loss per trade.
WIN% = the percentage of winning trades. TRDS = the number of trades taken.
The last two rows (AVG and STDEV) show the averages and standard deviations

(respectively) across all markets for the various performance figures.
In-sample, the British Pound, the Japanese Yen, Feeder Cattle, Live Hogs,
and Lumber were the only markets that bad positive returns. Only the
Deutschemark had a strong return on account at 25.9% annualized. Out-of-sam
ple, the NYFE, the Japanese Yen, Light Crude, COMEX Gold, Palladium, Live
Hogs, Soybeans, Soybean Meal, Coffee, and Orange Juice had positive returns.
Only the Japanese Yen and Live Hogs were profitable in both samples. The ran-
dom entry system was among the least consistent systems of those examined in the
study of entries.
The average trade, across all markets, lost $1,731 in-sample and $1,734 out-
of-sample. Long trades lost less than shorts, a finding observed many times. In-
sample, all the currencies, except the Canadian Dollar and Eurodollars, were
profitable on the long side. These are trendy markets, and therefore, such prof-
itability is likely due to the behavior of the standard exit, not to chance factors
involved in the random entries.
The analysis of the standard exit with random entries taken using various
entry orders should serve well as a baseline of comparison for both the real, non-
random entries (studied in earlier chapters) and the more sophisticated exits (to be
studied in subsequent chapters).

The next test involves changing the SES a bit, thus producing the modifkd stan-
dard exit strategy (MSES). The SES is made more realistic by allowing the money
management stop and profit target limit to function inside the bar, not merely at
the close. To avoid ambiguities in the simulation when using end-of-day data, all
entries are now restricted to the open. This allows complete freedom to explore a
wide range of exit strategies. Other than lifting the restriction to the close, the
MSES is identical to the original SES used when testing entries. The rules for the
MSES are as follows: Upon entry, set up an exit stop below (long positions) or
above (short positions) the entry price and an exit limit above (long) or below
(short) the entry price. Place the exit stop some multiple (the money management
stop parameter) of the average true range away from the entry price. Place the exit
limit some other multiple (the profit target parameter) of the average true range
away from the entry price. Exit on the close after 10 days have elapsed if neither
the money management stop nor the profit target limit has yet closed out the trade.
A 50.bar average true range is used in these rules. The code below implements
random entries at the open together with the modified standard exit strategy.
CHAPTER 13 The Standard Exit strategy
The code used to run the current test is identical to the code used for the ear-
lier test, except for changes required by the modified exit strategy. A trade is
entered on a random signal that is generated as discussed earlier. However, buying
and selling occur only on the open. In addition, information is recorded about
entry activity, i.e., whether an entry (long, short, or none) was posted on the cur-
rent bar (entryposted), the price (entryprice) at which the entry took place (if one
was posted), and the bar on which it took place (entrybar). This data is required in
computing the exits. The exits are then generated. If an entry is posted for the next
bar (i.e., if the market is entered long or short at the open of the next bar), a prof-
it target and a stop loss are also posted for that bar. For the longs, the stop loss, or
money management stop, is set at the entry price minus a parameter that is multi-
phed by the average true range. The limit price for the profit target is set as the
entry price plus another parameter that is multiplied by the average true range. If,
on the current bar, a short entry is posted for the next open, then orders are also
posted to exit the resulting short position on a limit or a stop. The limit and stop
are calculated in a manner similar to that for the longs, except the directions are
flipped around. If a given bar is not an entry bar, a check is made to determine
whether there is an existing position after the close of the bar. If there is, two
orders (possibly three) are posted: the money management stop and profit target
limit orders, using the stop and limit prices calculated on the bar the entry was ini-
tially posted; and if the trade has been held for more than maxhold bars, an order
to exit on the close is also posted.


Test 4: MSES with Random Entries at Open. Table 13-5, which has the same
format as Tables 13-l through 13-3, provides data on the portfolio performance of
the modified standard exit strategy with trades entered randomly at the open, In-
sample, the average trade. lost $1,702, with a standard deviation of $365. The per-
centage of wins was 31.73%, with a standard deviation of 1.10%. The average
trade lost less than it did in the tests of the original, unmodified SES. The reduc-
tion in the loss on the average trade was undoubtedly caused by the ability of the
MSES to more quickly escape from bad trades, cutting losses short. The more
rapid and frequent escapes also explain the decline in the percentage of winning
trades. There were fewer wins, but the average loss per trade was smaller, an inter-
esting combination. Overall, the MSES should be regarded as an improvement on
the unmodified standard exit.
Out-of-sample, the average trade lost $836. Statistically, this was signifi-
cantly better than the in-sample performance. It seems that, in more recent years,
this exit provided a greater improvement than it did in earlier years. The markets
may be more demanding than they were in the past of the ability to close out bad
trades quickly. Other figures in Table 13-5 indicate a similar pattern of changes.

Market-by-Market Results for MSES with Random Entries at Open. Table 13-
6 contains the market-by-market results for the MSES with the best set of random
entries taken at the open. The best set was chosen from the randomizations shown
in Table 13-5. The Swiss Franc, Light Crude, Heating Oil, COMEX Gold, and
Live Cattle had positive returns both in- and out-of-sample. For some markets, the
MSES was able to pull consistent profits out of randomly entered trades! Many
more markets were profitable in both samples than when the unmodified SES was


Results for the Modified Standard Exit with Random Entries
at the Open
used, again a sure sign that the more responsive, modified exit is better. As usual,
and across both samples, the long side was more profitable (lost less) than the
short side. Surprisingly, out-of-sample, the long side actually turned a very small
whole-portfolio profit with this exit strategy; it is, however, nothing one would
want to trade.

TABLE 13-6

Market-by-Market Results for the Modified Standard Exit
with Random Entries at the Open

The results clearly demonstrate that many of the entry strategies tested in earlier
chapters using the SES were no better than random entries. Sometimes they were
worse. The results also indicate that the SES is not a great exit strategy. The
MSES, which simply lifts the restriction of the exit to the close, performed much
better and even managed to pull a small profit out-of-sample on the long side. The
MSES should still be considered a minimalist exit strategy, but the results support
the contention that a really good exit strategy is, more than anything else, the key
to successful trading. If the findings from this and previous studies are correct, it
should be possible to find an exit strategy that can actually extract substantial prof-
its from randomly entered trades, at least in some markets. Such an exit strategy
would substantiate what many great traders have said: An experienced trader,
skilled in money management, can make a profit even with a bad system, while a
novice trader, unskilled in money management, can lose everything trading a great
system (sysrem, in this context, usually referring to an entry model). In all the
remaining tests in this book, the MSES will replace the original, unmodified exit
strategy (SES).


. A good exit strategy is extremely important. It can even pull profits from
randomly entered trades! Think of what it could do for trades entered on
the basis of something better than the toss of the die.
. Even simple modifications can make a big difference, as evidenced by the
results above where slight changes proved effective.
. When combined with the suboptimal SES, many of the entry strategies
tested in the previous section of this book can be seen to perform no bet-
ter than the random one. Some even did worse! Of course, a few per-
formed dramatically better than did the random entry model.

Improvements on the Standard

In continuation of the endeavor to improve upon the standard exit strategy (SES)
and develop a good exit, a number of modifications are explored. In the previous
chapter, it was demonstrated that the exit strategy can have a substantial impact on
the overall performance of a trading system. To make it more compatible with the
kinds of exit strategies examined in this and the next chapter, the original SES
(used in the study of entries) was changed and became the modified SES (or
MSES): While maintaining consistency, the restriction of exiting at the close was
removed. It was no longer necessary to restrict the exit to the close, because in the
study of exits, entries are restricted to the open. In previous chapters, entries were
not restricted to the open. Therefore, to avoid ambiguity in the simulations, it was
necessary to restrict exits to the close. The MSES represents a kind of baseline,
minimalist exit that can serve as a standard for comparing better exit methods, as
well as provide some consistency and comparability with the unmodified SES. In
this chapter, variations, both small and large, of the MSES are explored in an
attempt to find a better exit strategy.

When specifying the original SES (as well as when modifying it so that inside-the-
bar stops and limits could be used), specifications for the tightness of the money
management stop and closeness of the profit target were arbitrary and fixed. For
long entries, the money management stop was placed at 1 average true range unit
below the entry price, while the profit target was placed 4 average true range units
above the entry price. For short entries, the placements were reversed. The inten-
tion was to place a stop fairly close in so that losing trades would quickly be taken

out, while placing the profit target far enough away so profits would not be cut
short on trades that were favorable. The first test below examines the performance
of the stop and profit target when the arbitrary settings are adjusted.
The second set of tests involves replacing the fixed money management stop
in the MSES with a more dynamic stop. The minimalist MSES lacks many desir
able characteristics. One of the features any good trader wants in an exit is the abil-
ity to lock in at least some of the paper profit that develops in the course of a
successful trade, i.e., to avoid having to watch profitable trades turn into losers.
Locking in some of the profit can be accomplished using a trailing stop: Instead
of having a money management stop placed a fixed distance from the entry price,
the stop moves toward current prices as the trade becomes profitable. As prices
move in the trade™s favor, the stop moves in along with them, locking in a propor-
tion of the developing profits. Should the market reverse, the trade will not be
closed out at a loss, as might have been the case with the tixed stop, but at a prof-
it, if the moving stop has gone into positive territory. There are several strategies
for the placement and relocation of a stop designed to prevent winning trades from
turning into losers and to lock in as much of the unrealized profit as possible. The
second set of tests explores such strategies.
Originally, the profit target in the MSES (and SES) was implemented as a
limit order with a fixed placement. In the third set of tests, the fixed profit target
is, like the stop in the previous tests, replaced with something more dynamic. It
would be desirable if the profit target could also move in toward the prices, espe-
cially in languishing trades. This would enable the trader to exit at a better price,
perhaps even with a small profit, in the absence of strong, favorable movement.
Exiting the market on spikes or noise should lead to more profitable trades than
simply exiting on a time constraint or waiting for the money management stop to
be hit. At the same time, the trader does not want the profit target to cut profits
short. A profit target that is too close might provide a higher percentage of win-
ning trades, but it will also significantly limit the size of the profits. In all likeli-
hood, it will cause the overall strategy to perform less well. It should be
advantageous to make the profit target dynamic in the same way that the stop was
made dynamic, i.e., to place the profit target far away from the market at the begin-
ning of the trade, or when the market is steadily moving in a favorable direction,
In this way, it would not be necessary to settle for a small profit on a potentially
very profitable trade; the trader could “let profits run.” Conversely, in trades that
are languishing, or when the market is exhibiting blow-off behavior, the profit tar-
get could be made to move in tight to close out the trade, and to do so at the best
possible price, before the market has a chance to reverse. Modifications of the
profit target limit order placement are studied below.
Finally, the time limit exit from the MSES model is adjusted and tested on
the assumption that, with effective dynamic stops and profit targets, a short time
limit is no longer so necessary. Trades will be exited quickly by other means if
they are languishing, but will be held for as long as possible if favorable move-
ment is occurring. The intention is to let profits develop and not be cut short sim-
ply because of an order to exit on an arbitrary time limit.

The MSES makes use of a fixed stop and profit target that do not change their place-
ments during a trade. Originally, the parameters for the placement of these stops
were somewhat arbitrxy and certainly not optimal. What happens when these para-
meters are stepped through a range of values in search of an optimal combination?
In this test, the money management stop parameter is stepped from 0.5 to 3.5
in increments of 0.5. The profit target limit parameter is also stepped from 0.5 to
5 in increments of 0.5. The profit target parameter is simply the multiple of the
average true range used in placing the profit target limit. Likewise, the money
management stop parameter is the multiple of the average true range used for plac-
ing the money management stop.

float *lo, float '˜1s. float *vol. float *oi. float +dlrv, int nh,
TRDSIM fcts, float l eqcls) (

The code implements the standard random entry at the open and the modi-
fied standard exit strategy. The rules for the exit are as follows: A limit order exit
is placed a certain number of true range units above (long) or below (short) the
entry price. The number of true range units that the limit order is placed away from
the entry price is specified by the parameter ptlim. Besides the profit target limit,
an exit stop is placed a specified number of average true range units below (long)
or above (short) the entry price. The parameter mmsrp determines the number of
true range units that the stop is placed away from the entry price. Finally, maxhold
is a parameter that specifies the maximum time any position is held. If they were
not closed out ,earlier by the profit target limit or money management stop, all
trades will be closed out with an exit at the close after maxhold days or bars have
elapsed since entry. In the test, maxhold is fixed at a value of 10, the same value
used throughout the tests in this book.
Table 14-l shows the annualized risk-to-reward ratio (ARRR), the percent-
age of winning trades (WIN%), and the average trade profit or loss (AVTR), for
every combination of money management stop and profit target limit parameter
settings. At the right of the table, the AVG or average values (average taken over
all money management stop parameters) for all the performance figures are pre-
sented for each profit target limit parameter value. At the bottom of the table,
the AVG or averages (taken over all profit target limit parameters) for each of the
money management stops are shown.
A number of things are immediately apparent in the results. As the profit tar-
get limit got tighter, the percentage of winning trades increased; this was expected.
A tight profit target has a greater chance of being hit and of pulling a small profit
out of the market. However, the increased percentage of winning trades with
tighter profit targets was not sufficient to overcome the effects of cutting profits
short on trades that had the potential to yield greater profits. Looser profit targets
performed better than tight ones. For most of the profit target limits, there was an
optimal placement for the money management stop, between a value of 1.0 and
2.0 average true range units away from the entry price. As the stop got looser, the
percentage of winning trades increased, but the other performance figures wors-
ened. As it got tighter, the percentage of winning trades declined along with the
other measures of performance.
The overall optimal performance, in terms of both annualized risk-to-reward
ratio and average trade, was with a profit target limit of 4.5 and a money manage-
ment stop of 1.5. As deviation from the optimal combination occurred, the annu-
alized risk-to-reward ratio increased, as did the average loss per trade. There was
relatively little interaction between placement of the profit target and the money
management stop. The values that were optimal for one varied only slightly as the
parameter controlling the other was adjusted. Another almost equally good com-
bination of parameters was 1.5 and 4 (profit target and stop, respectively). This
provided a very slightly better average trade and a trivially worse annualized risk-
to-reward ratio. It is interesting that the arbitrarily assigned values came fairly
close to the optimal values, appearing only one cell away from the optimal cells in
Table 14-l. The optimal values, however, provided 6% more winning trades than
the arbitrary values of 4 (profit target) and 1 (stop).
TABLE 14-1

In-Sample Portfolio Performance with Modified Standard Exit and
Random Entry as a Function of Profit Target Limit (Left) and Money
Management Stop (Top) Parameters

The percentage of wins for the optimal solution was 39%. When the num-
bers were examined in relationship to those for a profit target limit of 0.5 (with the
same stop), 69% (instead of 39%) winning trades resulted, but with a much worse
risk-to-reward ratio and average trade. This clearly shows the importance of let-


. 7
( 9)