<< . .

. 28
( : 30)

. . >>

are there, they are difficult to find.


I n this chapter, the modified standard exit strategy (MSES) is explored with the
addition of elements based on neural networks and genetics. In Chapter 11, neur-
al network forecasters were developed for use in generating entries. One of the
particular neural forecasters (the time-reversed Slow %K net) attempted to predict
whether tomorrow™s prices would be near the low or high end of the range of
prices that would occur over the next several days. This network can be added to
an exit strategy: If the net suggests that the market is near the top of its near-future
range and a long position is being held, it would probably he a good idea to exit
before the market begins to move down. Likewise, if the net forecasts a rising
market while a short position is being held, the trade should be exited before the
market begins to rise.
The first test conducted below explores the use of the time-reversed Slow
%K network (developed when studying entries) as an additional element to our
modified standard exit strategy. The net, which generates what might be called a
signal exit, cannot be used on its own for exiting because it will not always close
out a trade. This network was designed to provide entry signals. When it generates
a signal, the market is likely to behave in some expected manner. However, the
absence of a signal does not mean that the market will not do something signifi-
cant. When a position is being held, at some point an exit has to be taken, and that
action cannot be postponed until a significant event is finally predicted. The
MSES, in this case, guarantees that all trades have some money management pro-
tection and are exited after a given amount of time. The neural net, however, can
possibly improve the strategy by occasionally triggering an exit when a predicted
move against the trade is expected. In this way, the net may turn a certain propor-
tion of losing trades into winners.
The second batch of tests (one for the long side, one for the short) involves the
use of a genetic algorithm to evolve a set of rules tcr generate a signal exit. The rules
are used in a manner similar to the way the net is used, i.e., to generate additional
exits, witbin the context of the MSES, when the market is likely to reverse. The rule
templates and rule-generating methodology are the same as those used in Chapter
12, where evolved rules generated entries. In the current tests, rules are evolved to
generate additional exits within the context of the MSES. The rules are used as sig-
nal exits. The additional exits will, it is hoped, improve profitability by turning some
losses into wins and by killing other trades before they become larger losses.
More sophisticated exits can be developed using the techniques described above.
Although not explored in this chapter, a neural network could be evolved to produce
outputs in the form of placements for stops and limits, as well as for immediate, out-
right exits. Genetically evolved rules could also be employed in this manner.
When used in the context of entries, neural networks proved to be fairly good
forecasters. It-sample, incredible profits were produced due to the accurate pre-
dictions. Out-of-sample, the nets yielded much better than chance results (albeit
not very profitable on the whole portfolio). Real predictive ability was demon-
strated. Using such forecasts to exit trades before the market reverses should
improve system performance, even if only by eliminating a small percentage of
bad trades. The same applies to the genetically evolved rules. However, when the
rules that produced entry signals for rare event trades are applied to exits, great
improvement in exit performance should not be expected. Given the nature of the
rules, only a small number of signals are likely to be generated, which means that
only small numbers of trades will be affected. If only a few of the large number of
trades that will be taken are improved, only a small overall benefit will be evi-
denced. Since the rules are being reevolved for the tests below, more inslances of
exit opportunities may be found than were discovered for entry opportunities.

The larger of the two best neural networks, trained to predict the time-reversed
Slow %K, are used. The preprocessing and forecast-generating logic are identical
to those discussed in Chapter 11. A series of predictions are generated using the
18-14-4-1 net (18 first-layer neurons, 14 neurons in first middle layer, 4 in the sec-
ond middle layer, and 1 output). The MSES is also used. Along with the exits pro-
vided by the MSES, an additional exit condition is being added: If the predicted
reverse Slow %K is greater than some threshold, indicating that the market is high
relative to its near-future price range, any long position is exited. Likewise, if the
net™s prediction indicates that the market is near the low of its neat-future price
range, by being below 100 minus the previous threshold, any short position is exit-
ed. Exits triggered by the neural net forecasts are taken at the close of the bar.

// exit trades using the modified standard exit
// strategy along with the neural signal exit
iflentrypasted z 0) (
// initialization and exits for longs on entry day
limprice I entryprice + pt1im * exitatrLcb1;
stpprice = entryprice - mstp * exitatr[cbl ;
ts.exi˜longlimit(,A', limprice);

ts.exitlo*gstop˜˜B™, srppsice);
if(prd[cbl > thresh) ta.exitlongclose('C');
e1ae if˜entryposted < 0) (
/I initialization and exits for shorts on entry day
limprice - entryprice - ptlim * exitatr[cbl;
stpprice = entryprice + mmstp * exiratr[cbl;
ta.exitshortlimit('o', limprice);
t˜.exiCshortst˜p('E', atpprice);
if(prdLcbl < loo.o-thresh, te.exirshortclose('P'l:
else (

The code fragment above implements the logic of the exit strategy. The para-
meters ptlim and mmsrp are set to 4.5 and 1.5, respectively; these are the values
that gave the best overall portfolio performance (see Table 14-1, Chapter 14). The
thresh parameter, i.e., the threshold used to generate exits based on the neural fore-
casts, is optimized. The logic of the additional exit can be seen in the “if™ state-
ments that compare the prediction of the network with the threshold and that post
an exit at close order based on the comparison. The parameter thresh is stepped
from 50 to 80 in increments of 2.

Baseline Results
Table 15-l contains data on the baseline behavior of the MSES. The threshold
..was set high enough to prevent any net-based exits from occurring. The numbers
in this table are the same as those reported in Chapter 14 (Table 14-I) for an opti-

ma1 fixed stop and profit target. The abbreviations in Table 15-l may be inter-
preted as follows: SAMP = whether the test was on the training or verification
sample (IN or OUT); NETL = the total net profit on long trades, in thousands of
dollars; NETS = the total net profit on short trades, in thousands of dollars; PFAC
= the profit factor; 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; WIN% = the percentage of winning trades; AVTR = the average prof-
it/loss per trade; and TRDB = the average number of bars or days a trade
was held.
There was great consistency between in- and out-of-sample performance:
The average trade lost $1,581 in-sample and $1,580 out-of-sample; both samples
had 39% winning trades; and the risk-to-reward ratios were - 1.46 in-sample and
- 1.45 out-of-sample.

Neural Exlt Porlfolio Results
Table 15-2 is the standard optimization table. It shows the in-sample portfolio per-
formance for every threshold examined and the out-of-sample results for the
threshold that was the best performer during the in-sample period.
In-sample, an improvement in overall results was obtained from the use of
the additional neural network exit. The average trade responded to the threshold in
a consistent manner. A threshold of 54 produced the best results, with an average
trade losing $832. There were 41% wins and an annualized risk-to-reward ratio of
-0.87. The numbers represent a dramatic improvement over those for the baseline
presented in Table 15-l. Out-of-sample, however, no improvement was evident:
Performance was not too different from that of the optimal MSES without the
neural signal element. In the tests conducted using the neural net for entries, per-
formance deteriorated very significantly when moving from in-sample to out-of-
sample data. The same thing appears to have happened in the current test, where
the same net was used as an element in an exit strategy.

Baseline Performance Data for the Modified Standard Exit Strategy
to Be Used When Evaluating the Addition of a Neural Forecaster
Signal Exit

IN I -19761 -4073) 0.831 -10.31 -1.461 1.0000˜ 38261 391 -15811 6
OUT I -9741 -163zl 0.641 -21.61 -1.451 O.BS651 16491 391 -15501 8
CHAPTER 15 Adding AI to Exits

TABLE 15-2

Portfolio Performance of the Modified Standard Exit Strategy with an
Added Neural Signal Exit Evaluated over a Range of Threshold
Parameter Values

Neural Exit Market-by-Market RBBUitB

Table 15-3 shows the performance data for the portfolio, broken down by market,
for the optimal MSES with the added neural signal exit. The results are for tire
composite exit with the best threshold value (54) found in the optimization pre-
sented in Table 15-2.
Live Hogs was the only market that was substantially profitable in both sam-
ples. A number of markets (e.g., the Deutschemark and Japanese Yen) showed
strong profitability in-sample that was not evident out-of-sample. On the long side,
the NYFE and Unleaded Gasoline were profitable in both samples. This could eas-
ily be a statistical artifact since, in-sample, a large number of markets had prof-
itable performance on the long side.

Since it is almost certain that different rules are required for the long side, as opposed
to the short side, two tests are rtm. In the first test, random entries are generated for
long positions using the standard random entry strategy. Any short trades generated
are simply not taken. Rules are genetically evolved for inclusion in the MSES for the
long positions. In the second test, only short entries are taken. Any long entries gen-
erated by the random entry strategy are ignored. An attempt is made to evolve rules
that work well as additional elements to the MSES for the short side.


Market-by-Market Performance for the Modified Standard Exit with a
Neural Signal Addition Using Random Entries

The code above shows the logic of both the entries and exits. The modeltype
parameter controls whether the longs or shorts are tested. Parameters ptlim and
mmsfp are for the profit target and stop (respectively). They are fixed at the same
optimal values used in the neural network test earlier, Each of the three rules is cal-
culated as a series of TRUE/FALSE values, and if all three rules are TRUE, a rule-
based exit signal (exitrig) is generated. In the exit code, “if™ clauses have been
added. For example, an exit at the close is generated ifan exit signal is produced
by all three rules being TRUE (exitsig = TRUE). The evolution of rules for the
long and short sides follow the same steps as in the chapter on genetics, in which
similar rules were evolved for use in entries. The same 12 parameter chromosomes,
broken into three genes (each specifying a rule), are employed, and there is no
change in that logic in the current test, Rules for the short side and for the long
side are produced by allowing 2,500 generations to pass (2,500 runs using
OptEvolve). The top 10 solutions for the longs and for the shorts are then tested
on both the in-sample and out-of-sample data.

Top 10 Solutions with Baseline Exit
Table 15-4 shows the top 10 solutions found for the long side and for the short
side. In the table, LINE = the line or generation number; PROB = the probabili-
ty or statistical significance (the decimal point is omitted but implied in the for-
matting of these numbers); $TRD = the average dollars-per-trade; TRDS = the
total number of trades taken; PFAC = the profit factor; and AROA = the annual-
ized return-on-account.
The best solution for the longs was discovered in the 845 generation of the evo-
lutionary process. For the short side, it was in the 1,253 generation. ln contrast to the
situation when rules were evolved for use in an entry model, none of the solutions
were profitable. However, Table 15-5 shows that when genetically evolved rule-based
exits were added, substantial improvement over the baseline was achieved.
The rules in Table 15.4 were translated into plain language. The rules for
exiting a long position were as follows: If the close on the current bar is greater

TOP I 0 Solutions from the Evolutionary Process
for Longs and for Shorts
than a 12.bar exponential moving average (EMA) of the closes, but is less than a
49-bar EMA of the closes, and the current bar represents a 6.bar new high, then
exit the long trade. The rules seem to be searching for a situation in which the
longer trend is down, but a short-term retracement against the trend has occurred
and has reached a point where completion of the retrxement is likely and the
longer-term downward trend will resume-a sensible point to exit a long position.
The rules for the short side suggest that an exit should occur if the close on the
current bar is greater than the 16-bar EMA of the closes and a 22.bar simple mov-
ing average of the closes, and if the MACD is sloping down. The specific MACD
used employs a 6-bar EMA for its faster moving average and a lo-bar EMA for
its slower moving average. The idea encapsulated in these rules seems to be that
it is wise to close out short positions if the market, when smoothed, still appears
to be moving down, but the most recent close broke above two moving averages,
indicating the market may be starting a new trend up.

Results of Rule-Based Exits for Longs and Shorts
Table 15-5 presents the performance data for best of the top 10 solutions (longs
and shorts) for the MSES with the addition of genetically evolved, rule-based
signal exits. Trades were entered randomly. The table is broken down into results
for long positions and results for short positions. It is further broken down by sam-
ple and test. Sample (IN or OUT) and test may be BSLN (when the rules were not
used) or RULE (when the mles were. used).
On the long side, in-sample, the addition of the genetically evolved rule-based
exit substantially reduced the loss on the average trade from a baseline of $688 to $324.
The percentage of winning trades increased from 41 to 43%. The annualized risk-to-


Performance of the Modified Standard Exit Strategy with an Added
Genetically Evolved Rule-Based Signal Exit When Trades Are
Entered Randomly
reward ratio improved from -0.35 to -0.17. Out-of-sample, the benefit of the genet-
ically evolved mle-based signal exit was maintained, but not quite as dramatically. The
loss on the average trade was cut from $1,135 to $990. The percentage of winning
trades increased from 39 to 41%. The risk-to-reward ratio improved slightly from
-0.61 to -0.60. Overall, adding the genetically evolved rule-based element to the exit
strategy worked. In contrast to the neural exit, the benefit was maintained out-of-mm
ple, suggesting that curve-fitting and over-optimization were not major issues.
On the short side, similar benefits were observed in both samples. In-sample,
the addition of the genetically evolved rule-based element reduced the loss on the
average trade from a baseline of $2,084 to $1,645. The percentage of winning
trades remained unchanged. Paradoxically, the annualized risk-to-reward ratio
worsened somewhat, going from - 1.09 to - 1.15. Out-of-sample, the loss on the
average trade dropped substantially, from $1,890 in the baseline test to $1,058,
when the rule element was active. The percentage of winning trades rose from 38
to 40%, and the annualized risk-to-reward ratio improved, from - 1.02 to -0.73.
Again, the addition of the genetically evolved rule-based signal exit to the MSES
worked and continued to work out-of-sample.

Market-by-Market Results of Rule-Based Exits
for Longs
Table 15-6 contains information regarding the market-by-market performance of
the MSES for the long side, with the added rule-based signal exit. Several markets
showed profitability in both samples: the NYFE, Light Crude, Unleaded Gasoline,
and Live Hogs. Other markets were profitable in-sample, but lost heavily out-of-
sample (and vice versa). The consistency between in-sample and out-of-sample
results was not high.

Market-by-Market Results of Rule-Based Exits
for Shorts
Table 15-7 shows the same market-by-market breakdown as in Table 15-6, but
only the short side is represented. More consistency was evident between in-sam-
ple and out-of-sample performances for the short side than for the long. Most
notably profitable in both samples was the Japanese Yen. Light Crude, Unleaded
Gasoline, Feeder Cattle, Live Hogs, Soybean Meal, and Coffee were also prof-
itable in both samples.

Several important points were demonstrated by the above tests. First, neural net-
works hold up less well in out-of-sample tests than do genetically evolved rule-
based solutions. This is no doubt a result of the greater number of parameters
Market-by-Market Performance of the Modified Standard Exit with an
Added Genetically Evolved Rule-based Signal Exit When Tested
Using Random Long Trade Entries

involved in the neural network model, as compared with the rule-based models
being used. In other words, the effects of curve-fitting were damaging to the neur-
al network solution. Also discovered was the fact that the addition of a sophisti-
cated signal exit, whether based on a neural net or a set of genetically evolved
entry rules, can greatly improve an exit strategy. When the more robust, geneti-
cally evolved rules were applied, the performance benefits obtained persisted in
out-of-sample evaluations.
The neural network and the rule templates (but not the actual rules) that were
used in developing the signal exits were originally developed for inclusion in an


Market-by-Market Performance of the Modified Standard Exit with an
Added Genetically Evolved Rule-Based Signal Exit When Tested
Using Random Short Trade Entries

entry model. When the rules were used in an entry model, it was acceptable for
them to generate rare event trades. In an exit strategy, however, rules that tire more
frequently would be more desirable. There is every indication that a set of rule
templates (and ways of combining the rules to obtain signals), specifically
designed for use in an exit strategy, would provide much better results than those
obtained here. The same should be true for neural networks.

Curve-fitting can be bad not only when building entries, but also when

building exits.
n Sophisticated technologies, including genetic algorithms, can be effec-

tively used to improve an exit strategy.
. Even crude efforts to improve exits, such as those carried out here, can
enhance profits by several hundred dollars per trade.

A long road has been traveled since beginning the study of entry and exit strate-
gies. Sometimes the trip has been tedious and discouraging; at other times, stimu-
lating and surprising. As usual after extended journeys, the questions “What
knowledge has been gained?” and “How may that knowledge be applied?™ beg to
be answered. The first question will be addressed by a successively more detailed
examination of the results: going from discoveries made about the portfolio per-
formance of entire classes of models, to more specific model-order combinations,
down to an inspection of individual markets and how they are best traded.
The perspectives taken in the following discussions of what has been
achieved are analogous to views from an airplane flying at night. At first, the plane
is at a very high altitude: All that can be seen when looking down are large patch-
es of darkness (classes of models that are ineffective or lose) and some patches of
light (classes of models that, overall, work fairly well or, at least, perform better
than chance). This view provides a basic idea of which models are, overall, viable
relative to the entire portfolio of tradables.
The plane then descends. More detail is seen. It becomes evident that the
brightest spots are often formed by clusters of light having various luminosities
(model-order combinations that are, to one extent or another, profitable).
Occasionally the dark patches also contain small isolated points of brightness
(successful model-order combinations amid approaches that usually are ineffec-
tive). At this level, a number of dim areas can be seen as well (model-order com-
binations that are not profitable, but that have better than chance performance that
could be enhanced if combined with a good exit).
Finally, landing is imminent. It is possible to look inside the bright spots and
see their detail, i.e., the individual markets the various model-order combinations
trade best. The second question above can now be addressed: By identifying the
consistently profitable (across samples) model-order combinations and the mar-
kets best traded by them, a good portfolio trading strategy can be developed. At
this time, it will become clear that out of all the studies performed during the long
trip, enough has been learned to assemble a lucrative portfolio of systems and trad-

<< . .

. 28
( : 30)

. . >>