In the first part of this series, we looked at the history of neural networks and their first-generation use in trading applications. We discussed how the large institutional traders who tried to use this technology failed to increase trading profits despite spending millions of dollars on research and development. They failed because they tried to make the neural networks do too much and treated trading as a pure signal-generation process.
The nets were used so that if the net failed to be predictive out-of-sample, the entire system failed. Often, the net was used as the engine of the system. For example, the system signaled a buy if the neural net predicted prices would rise throughout the next five days and signaled a sell if it predicted prices would fall. This scenario created disastrous results and is one of the reasons why neural networks have such a bad name among many traders to this day.
However, if applied properly, neural networks can make a comeback, regardless of the poor reputation their misguided practitioners have earned for them.
NEW DIRECTION
In the early days of neural networks the development process involved training neural networks on a data set and testing out-of-sample on another data set that was 10% to 15% of the size of the trading set. Then, the system was traded for 10% of the training set size. Afterward, the network was retained.
This process took a lot of time. Now, computer speeds have increased by more than 90 times since 1992 and 20 times since 1995. Then, it could take six hours to train one neural network. This made technologies proven on less-sophisticated models, such as walk-forward testing, impractical. How big a difference has the additional computer power made? A network that took 90 minutes to train in 1994 can be trained in 45 seconds now. Suddenly, tools such as walk-forward testing are now an option.
This opens up other options. Before, limited computer power prevented pre-processing with multiple neural networks — for example, having five different networks with different inputs predict the same thing and using the individual results to create a composite. Almost invariably, the result was a “no prediction” due to too much disagreement between the models that resulted from too little training.
PROPER APPLICATIONS
Neural networks are not magic. They should be used as a part of an existing functional trading strategy. Instead of building our system around a neural network, we can use neural net technology to enhance an existing strategy. Thus, if the net fails, it won’t necessarily bankrupt us.
A much more robust application of neural nets is to develop a system, and then determine what additional information would improve the system. We then can use neural nets to develop those improvements.
This application can improve system profits by 20% to 100% without degrading the system by more than 20% if the network fails. But what can neural networks predict?
PREDICTIVE INDICATORS
Most technical indicators are based on smoothing with a moving average. This process introduces lag into the trading equation. Traders use these indicators to make trading decisions, which means that traders’ decisions also have lag. If a version of these indicators could be created with less lag, system performance could be greatly improved.
For example, many mechanical trading systems use a technical indicator such as the average directional movement index (ADX) to filter trades. Some of these systems have performed well throughout time. A 14-day ADX suffers from about five days of lag. Using a neural network, lag can be cut to about zero and greatly improve the performance of the system. Neural network based momentum indicators such as the moving average convergence divergence (MACD) can be used.
Pattern recognition is another area where the strengths of neural networks can offer some benefits. Neural networks along with a technology called “kernel regression” are good at recognizing patterns. If a computer can automatically recognize a chart pattern, it can be traded and backtests can be developed to see how predictive each pattern is.
Pattern recognition offers a bridge between discretionary chart-based traders and mechanical system traders. Chart patterns are difficult to develop into 100% mechanical rules for identification. Mechanical rules might get you 70% to your goal but you will miss some patterns or have many false positives. Using a neural network to recognize the existence of a pattern is a good way to solve this problem.
However, identifying chart patterns is not easy and requires a lot of preprocessing. Data needs to be normalized across the period where chart patterns are being sought. A methodology such as point-and-figure charting can be used to create a matrix. The information in that matrix can then be input into the neural network, which can use that information to more reliably identify classic chart patterns.
Another benefit of this is that classic chart patterns look the same across markets. Normalization of this process removes price levels. Therefore, a triple top in the S&P 500 chart looks the same as a triple top in a corn chart (see “Digital triple,” below).

This triple top matrix was created with preprocessing using “X = 1” and “O = 0” in a standard point and figure chart. A “–1” is entered in the matrix so there is a representation for blank cell values giving each input a value when the network is trained.
TREND, VOLATILITY
Neural networks also can be useful in predicting trend and volatility. This type of prediction can be valuable as a filter for a trading strategy by providing insight into trend direction or mode. Predicting volatility with a neural network has value for option traders as well as system traders.
In terms of volatility, we could predict volatility moving into the future using this relationship:
AR3 / CA80, where
AR3 = average range of the next three bars, and
CA80 = the current average range of the previous 80 bars.
By doing a little algebra on this formula, the AR3 can be predicted, which could be used to set stops away from the herd. In addition, option traders could use this information to calculate future volatility in designing option strategies. This volatility information could also be used to predict large range days that are likely to close at price extremes making them profitable using opening-range breakout strategies.
PRICE CHANGE
Predicting price change and price itself is the third rail of neural networks. These methods are financially fatal in the hands of traders who do not know how to use them.
The problem with predicting price change or price is that most people have no clue how to predict price and then use the predictions incorrectly. Price change prediction can be right on direction or magnitude, but rarely both.
Price change and price prediction solutions cannot be judged based on predictive value correlation to actual because the root mean square error is not the important factor. The distribution of errors is the important factor.
A model that totally misses the five largest moves but is not on the wrong side of them could have a high correlation because it produces an output around zero, which is effectively shooting down the middle. This happens when we try to predict price change, the ratio or log of the ratio of prices throughout time.
When these neural nets fail, they tend to do so spectacularly with high negative correlations between predicted and actual results. This is why when using them, it is important to monitor the correlation between predicted and actual and turn the net off if it stops performing.
Another issue is exactly how to predict price change or price. It not as simple as using “close + 5 days into the future – close” or “log (close + 5 days into the future / close).” Using this method will not work because the error the network trains to is not low enough to produce optimal system results. This makes predicting price change very difficult and failure rates are quite high.
You need to use strategies like predicting the error between a linear regression model and actual results and post processing the output to obtain the results you are seeking. This helps because developing a model that is somewhat predictive using standard statistical methods and improving it with advanced techniques is likely to produce performance similar to the standard methodology when the network fails rather than a disaster.
An effective way to predict price or price change models is to apply standard modeling methods to making a prediction of your target and having the neural network predict the error in the standard model forecasts. This is a very powerful approach. We would use something such as linear regression to predict price and develop a neural network with the goal of predicting the error in the price forecast. If the predictions of the network are used, the error can be added to the regression forecast giving a reasonable chance of developing a useful robust forecast.
ON TO TRADING
As we noted, it is best to start with a profitable trading strategy. We do not want to expose ourselves to disaster if the net suddenly turns into a random number generator.
The simplest example would be to replace a standard indicator with its neural network predicted counterpart. Another example could be built around a so-called “Taylor-based” trading system, which buys on a limit order at today’s low minus one tick. This could be viewed as using today’s low as a proxy for tomorrow’s low.
In the Taylor system, there are two major reasons for wanting a predictive indicator. Sometimes the system buys and the market collapses or the position is never entered because prices open and rally without ever retracing. If we use this low prediction, we could buy the market just above the predicted low and not miss trades that do not retrace. These are often trending days that produce large profits.
The first step in applying the actual neural network is to select your output target. If predicting indicators, it will simply be the indicator value “N” bars in the future. Because we cannot look into the future in most trading platforms, the input is shifted backward. So, if we are trying to predict the ADX three days into the future, we would use today’s ADX value as our target and shift our inputs back three bars.
Here’s the code:
Sub PreProcessFrag()
Dim ADXValue as bararray
Dim PlusDMIValue as bararray
Dim MinusDMIValue as bararray
ADXValue = ADX(10,0)
PlusDMIValue = DMIPlus(10,0)
MinusDMI = DMIMinus(10,0)
Print Formatdatetime(Date)," ",ADXValue[2]," ",PlusDMIValue[2]," ",MinusDMIValue[2]," ",ADXValue
End Sub
To develop the neural network inputs and targets without having to look into the future, use the current value of ADX and shift the input back. This is a standard trick used for all neural network based trading applications.
If we are predicting tomorrow’s low, we would predict the difference between tomorrow’s low and today’s low and add this correction to today’s low. We could also use regression analysis or pivot point equations and assume “S1” as tomorrow’s low and train the network to predict the error in the forecast. This method will produce much better results than trying to predict it directly.
After designing your output, find inputs that are predictive of the output. The use of scatter charts is valuable in developing your neural network inputs. Do not expect to find linear relationships in these changes, but look for non-linear patterns that when combined produce a powerful predictive effect.
An important step is normalizing the inputs. When developing inputs for use in a neural network, you would not use “Close-Close[5]” as an input because the relative price change does not mean anything throughout a long period. Normalize it. For example, “Log (Close / Close [5])” would be an example of normalized data for preprocessing.
Developing custom preprocessing methods is the best solution for developing effective neural network models, but there are quick and dirty methods for preprocessing. Mark Jurik developed this methodology in the early 1990s with “Level-0” and “Level-1” features. (both located at the end of the article)
The idea behind Jurik’s method is that the price series are assumed to be formed by cycles of different frequencies. If data were sampled at different frequencies, the samples would carry all the information in the series. To do this, we use sample blocks of data. If a block is further in the past, it is spaced further from the next block and is larger. The index determines how far back in time the center of the block is situated and is chosen such that it covers the period between the consecutive blocks. The indexes are provided as shown:
Row 1 = n and Row 2 = m
Row 1 = 1 2 3 4 5 7 9 13 17 25 33 49 65 97 129 193 257 385
Row 2 = 0 0 0 0 0 2 2 4 4 8 8 16 16 32 32 64 64 128
This strategy provides the neural network with the information it needs looking back in time without sampling every bar. For example, if we believe the price of gold affects the 10-year Treasury note for up to 50 bars, we would use the sample for Row “n” and there would not be 50 columns of inputs. We would sample the first five days and then our samples would become further and further apart because the further apart samples are trying to put up longer-term cycles. If we are trying to find a 30-day cycle, it can be reproduced sampling every five days without needing to sample every day.
Level-0 features are normalization between price and the exponential moving average of price, which are sampled using row N in this table. Level-1 features are normalized price change relative to a block moving average.
TRAINING & TESTING
Previously, when developing neural network systems, our preprocessing and target data were exported and the network was trained in a separate program. We used add-ins like Braincel and Ntrain to integrate the neural network solution into the trading system.
During the late 1990s, new products like NeuralShell Trader allowed in-line training of your neural network with walk-forward capabilities. This made developing neural network trading strategies easier, but the analysis was still limited to developing a neural network that worked on one market at a time.
With their neural network based add-ins, however, some modern trading applications, such as TradersStudio, can develop portfolio based neural network enhanced systems with integrated money management using in-line walk-forward analysis.
In the final installment of this series, we will do a case study showing how to develop and test a neural network enhanced trading system on a basket of markets.


Murray A. Ruggiero Jr. is a consultant in East Haven, Conn. His firm, Ruggiero Associates develops market-timing systems. He is editor-in-chief of Inside Advantage Gold Club (www.iagoldclub.com) and is the author of Cybernetic Trading Strategies (John Wiley & Sons). E-mail: ruggieroassoc@aol.com.
