Neural Networks in Trading: Choosing Inputs and Outputs

When you build a neural network one of the first things you need to decide is which values will be the inputs and which values will be the outputs of your network. The outputs are the values you want to predict – to make profit within a trading system – and the inputs are the values which will allow you to predict the outputs with enough accuracy as to constitute an inefficiency. Now choosing inputs and outputs is no trivial task as this constitutes the majority of the success or failure of a trading neural network. Within today’s post I am going to share with you some tips on how to choose inputs and outputs and how they may lead to inefficiencies in ways that may not be very intuitive. I am also going to explain to you why the most computationally sound input/output solutions may not be the best and why this is the case.

A neural network is formed by a set of function layers which turn a certain set of input variables (the input layer) into a given set of output values (the output layer). Between the input and output layers you will find a varied amount of layers and functions (neurons) – depending on what you choose – which will attempt to transform inputs into outputs with the least possible error. This is done with the help of training sets which allow the network to adjust its hidden layer coefficients to fit a set of data for which the input and output data are already known. The hope of course is that the network will hold at least the same predictive power within a non-trained set.

The first thing you need to choose when you build a neural network for trading is exactly what values you want to predict. Do you want to predict the next day’s close? The next week’s close? The next support or resistance level? Choosing the output of the network first allows you to know how you’re going to build your inputs as you need to choose values that are able to predict the desired output. A very important thing here is to consider how you will normalize the output and if the output falls into what the neural network is “best at doing”. Remember that in neural networks output values need to range from -1 to 1 (when using efficient sigmoid symmetric functions) since arbitrary outputs require the use of linear functions which are “very bad” at fitting the network.

Once you choose the output you want the next logical step is to build inputs that you believe are predictive towards this output. Certainly before building the network there is no way of telling if one input will be better than another but you can obviously reduce the amount of variables you will use by doing a PCA (Principal Component Analysis) to filter out those variables which are evidently and heavily correlated. For example you might be interested in predicting the next week’s close and you decide to use as inputs past weekly closes, open, highs and lows but it turns out that a PCA analysis – as an example, I don’t know if this is the case – tells you that the close and open are very correlated and therefore it makes sense to only use the close, high and low.

The PCA technique allows us to eliminate those variables which might be redundant within the network and therefore only increase complexity without increasing the quality of the results. Once you have a set of variables which are not correlated it is time to test how much predictive power they actually have against your desired output. If the results are initially discouraging it may be because you are missing an important piece of information within your inputs or because the shape of your output isn’t appropriate. For example if you want to predict the weekly close and you have attempted to normalize it  by diving it over the last week’s close and then dividing it by two then doing a different mathematical operation over the output might increase the predictive quality of your network. Sometimes including information related with all inputs within the output can be a handy trick to “force” the network into “using” every piece of knowledge it has although the results will vary and you will need to assess which one works better.

A very difficult aspect of neural network development for trading systems is to actually choose outputs which are useful for trading system development and yet accurate enough.  For example you may be tempted to choose outputs and inputs that are very efficient for the neural network – such as an output between 0 an 1 attempting to predict a week’s change – but it turns out that this is not predicted as well as predicting the week’s close because predicting the weekly change using weekly change data makes the network loose a very important piece of information (absolute support and resistance levels) which are derived from direct price information. From a computational point of view it seems like the best solution but from a trading point of view you’re missing a vital piece of information which is not included in weekly change data.

A very interesting thing I have found out in the networks I have developed for Sunqu is that the use of absolute price values is very good since the network learns about support and resistance levels as they develop, actually trading around them in a certain way. Obviously the actual calculations done by the networks and their meaning are not known (remember that a neural network is for all practical purposes a black box) but looking at how trades are executed by the network shows a certain “taking into account” of things such as support and resistance. Since price is what you want to capture then taking into account absolute price values and basing predictors on them is a more straighforward way to system building than attempting to develop indicator output based networks.

However this doesn’t mean that you couldn’t get good results in this way. Predicting things like RSI extremes will allow you to take advantage of rapid price movements before they happen and predicting moving average shifts in the long term will allow you to take long term trend following positions. Nonetheless whatever you want to predict (your output choice) needs to be accompanied by a very judicious decision of which inputs you will use, reinforced by an adequate PCA analysis which can show you the quality of your inputs and how well separated they are from one another. The pair choice will also be very important as certain pairs need fundamental inputs as they deeply affect the way in which they behave (a good example is a USD/CAD neural network using US oil futures data).

If you would like to learn more about my work in automated trading and how you too can get a true education in this field please consider joining Asirikuy.com, a website filled with educational videos, trading systems, development and a sound, honest and transparent approach towards automated trading in general . I hope you enjoyed this article ! :o)

Print Friendly, PDF & Email
You can leave a response, or trackback from your own site.

One Response to “Neural Networks in Trading: Choosing Inputs and Outputs”

  1. Obiwahn says:

    Hello Asirikuy,

    awesome Blog!

    Quote: “USD/CAD neural network using US oil futures data”

    Is there an overview or table on your page or somewhere about such correlations between currencies and other indices?

    Best
    Obi

Leave a Reply

WordPress › Error

There has been a critical error on this website.

Learn more about troubleshooting WordPress.