Thread: Can a neural network trade the markets effectively?

Results 1 to 4 of 4

  1. #1

    Default Can a neural network trade the markets effectively?

    I thought I'd share with you a little experiment I'm performing to see if a neural network can be trained to successfully trade an index and/or forex.

    Generally speaking, neural networks are trained by comparing the output it produces with an expected result and feeding the error back into the network so it can correct itself slightly. The next time the neural net is tested the output is slightly closer to the expect result.

    But herein lies the problem with teaching a neural network how to trade - who's to say the way you are teaching it is either the best or correct way. You are teaching it with your own knowledge and therefore own misconceptions and mistakes and the neural net will repeat those mistakes after training. I've seen neural nets use moving averages, entry/exit rules and other such inputs to make trading decisions. I want to get away from this.

    Wouldn't it be better to let the neural network figure out how to trade for itself?

    So the aim of the experiment is to start off with a completely random network and let it trade and record the results. I am not going to tell it what results I am expecting, but just reward the best results. I am going to use Darwins theory of natural selection to let the network "evolve" itself into a better trader. The network will spawn off several copies of itself with small random variations, let them all trade and take the best few networks and discard the rest. Then repeat the process until consistent and reliable results are achieved and no more improvements can be found.

    I also want to see what the optimum amount of data is necessary to produce the best network - e.g. for trading on daily candles do you need only 1 week of data or several months to make an accurate prediction.
    That's the theory anyway. Currently I have no idea if it will work and it may take several neural net configurations before I have some consistent data. What will be interesting is to see what kind of trading approach evolves, I'm going to start trading with daily candlesticks and it'll be interesting to see whether it decides buy and hold is the best or whether it tries to trade short term swings.

    Simple steps to start with, I am going to build a direction predictor. The output of the network will be a single neuron with 2 states - either BUY or SELL. I will input a range of candlestick data into the net and count how many pips are won/lost by the time the next candlestick is completed, then the net will evaluate BUY/SELL again.
  2. #2


    For the first experiments, networks will be kept/disgarded purely on the basis of the total number of points they achieve over the historical data. However I will weigh the points according to the index level. Gaining 1 point when the S&P was at 100 is a lot more significant than gaining one point when it was at 1200.

    I'm going to train the network on daily data from the S&P from 3-Jan-1962 to 31-Dec-2006. The S&P is relatively friendly to indicators given it's large number of constituents. I am keeping data from 1-Jan-2007 aside for forward testing, I think it will be interesting to see how any evolved network will cope with the credit crunch. I'm hoping by training on such a large range of data from '62 - '07 that the net will not become too optimised, however I can't guarantee this and I'm deliberately leaving out a pretty volatile period in history to see if the network can cope with this unseen data.

    Afterwards I will increase the complexity of the outputs - stating trade size, stop size and limits. I will also see if the evolved network is capable of trading other more tricky indices like the Dow Jones Industral and the Nikkei without ever having seen the data before.

    If any of this is successful I will move onto shorter timeframes in forex to see if a similar network can be built.
  3. #3


    articulate, interesting and challenging, as always.
    will follow with interest
  4. #4


    You are in for a LOT of work. At one stage I spent quite a lot of time fiddling around with TradingSolutions. It's hard to build decent ANN models. What TS does by default is construct an "optimal analog trading signal" using future knowledge according to certain parameters (eg profit 5% per trade) and trains the NN to predict this signal. It also runs the predicted signal thru a genetic optimizer to adjust he zero offset. Even with all the bells and whistles of a reasonable software package such as TS it's still hard to make any real progress.

    Even if you get a reasonable correlation between the optimal signal and predicted signal, the thing still does not necessarily trade profitably. In other words even with well chosen inputs, a suitable network and demonstrably some predictive ability you can still lose money. It really is difficult stuff.

    Good luck with training over 40 years of S&P data, I found that over those sorts of periods the training just doesn't converge. You can have too much training data as well as too little. Probably because of the changing nature of the market.

    One other possible application for ANN is not prediction, but classification and pattern recognition. One thing I have been thinking about is pattern recognition in order book behavior in futures markets. It's hard stuff, but probably no more difficult than time series forecasting.

    Anyway, good luck. Will be very interested to hear if you have any success.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts