Pattern Recognition (TASC December 2000)

Many expert technical traders make position decisions based upon trend lines placed through recent segments of the price curve. For many experienced traders, these trend lines don’t even need to be drawn. The human brain is capable of superimposing imaginary trend lines through price curves (Figure 1) and then subconsciously comparing these trend lines to trend lines from previous situations.

Those of us who are not expert technical traders lack the years of experience watching price movements. Our brains are not capable of placing these trend lines in the proper positions of the price curve, and have a limited database of previous trend line patterns with which to compare. However, some simple regression indicators combined with a powerful genetic algorithm optimizer can do the job for us.

The NeuroShell DayTrader Professional contains several types of linear regression indicators. One type is capable of placing imaginary line segments through various parts of a price curve and then reporting the slopes (angles) of these lines. A particular set of angles forms a pattern which can then be compared to future patterns to make trading decisions.

But where should trend lines be placed and how long should they be? Genetic algorithms are great for figuring that out because of their ability to simultaneously optimize many variables. In our pattern recognition task, we’d like to find the optimal:

1. number of trend lines to place on recent data,
2. lengths of the trend lines in bars,
3. time, in bars, prior to the current bar at which each trend line begins, and
4. the angles of the trend lines

all based upon maximizing profit or any one of a number of other objective functions.

In the NeuroShell DayTrader we loaded a DELL chart using 30-minute bars. We then inserted a trading strategy with a number of long entry rules which, in plain English, were:

“Buy long when the slope of a line of length x, placed y bars back, exceeds angle z.”

The genetic algorithm was instructed to find the proper number of these rules which should be true before a long order is placed, as well as the optimal settings for x, y, and z of each rule. Note that it is possible and even desirable for trend lines to overlap.

The genetic algorithm was also given a set of short entry rules, which were optimized with the long entry rules to create a total “reversal” trading strategy that was optimal for an issue over a given period of time. The short rules looked for slopes below a particular angle.

Appropriately, the NeuroShell DayTrader is set up to optimize over an earlier “in-sample” period and then back-test over a later “out-of-sample” period. We compared both the in-sample optimization period results and the out-of-sample back-test period results with the results from a “buy and hold” strategy. Figure 2 shows the in-sample period results, and Figure 3 shows the out-of-sample period results. Figure 4 shows the optimal rules found.

Interestingly, the pattern recognition strategy correctly anticipated the sudden earnings related drop in DELL stock between October 4th and 5th and went short October 4th. (Figure 5).

In this trading strategy we utilized only traditional indicator threshold rules. We did NOT use a neural network, although we often do feed similar optimized regression slopes into neural networks in the NeuroShell DayTrader in order to make trading strategies from neural predictions. We always make use of the NeuroShell DayTrader’s ability to do “walk forward” out-of-sample testing, giving us a reasonable indication that the model can generalize into the future.

For more variety, we might have also added some under threshold rules to the long entry rule set, and some over threshold rules to the short entry rule set. Another interesting variation on the use of regression slopes is insisting that slope angles not only be over or under thresholds but between thresholds as well.

Finally, you might experiment with restrictions on the ranges of variables. In our example, we accidentally placed some severe restrictions on some ranges before optimization, but the genetic algorithm compensated by adjusting other variables.





File Download

Was this article helpful?

Related Articles