Friday, August 21, 2009

Neural Networks

Years ago, I developed a neural network in C++ for a share trading system. It never succeeded because it either wouldn't learn anything, or when it did I couldn't get it to stop curve fitting. Recently after re-reading about early stopping in neural networks (and also remembering the success of Better in the 2007 MT4 championships) I decided to give it a go on forex, and have been immediately encouraged.

Behind the science of neural networks is craft: by trial and error the neural network environment needs to be massaged until it yields some promise. Here's what I have come up with so far.
  • Start with a simple non-NN entry strategy which is not profitable and yields large numbers of trades, then use the NN to filter these in much the same way as a more traditional long term moving average would be used. This idea came from http://articles.mql4.com/777. Right now I am using a cross 4 bar high for long and cross 4 bar low for short, and both Stoploss and Takeprofit of 100 pips.
  • Use a series of inputs to the NN which are the close price differences from the bars with shift 1,2,3,4,9,16,25,36,49,64,81,100,121,144,169,196,225,256,289,324. This is simply a gradually lengthening time between each close. Divide the difference by the square root of the time difference. This idea comes from Mark Jurik
  • Normalise the input vector
  • Use a standard simply connected 19-10-1 neural network
  • Here's the key new idea: early stopping -- run the learning backpropagation against factset 1 (say three months of 15 minute data), and select the NN which delivers the best equity curve on the following 3 months of data. Typically, and in agreement with many NN texts, the NN will continue to train past the point that it generalises
So here's what has happened so far in a short forward test from 7th August to 21st August - the equity has risen 700 pips with a max drawdown of 300 pips
Update on 26 August - I'm now running a forward test on my new virtual host

3 comments:

  1. How do you decide on the ideal number of hidden nodes?

    ReplyDelete
  2. Hi skajake, I mention in my post that use of Neural Networks is a craft, and the number of hidden nodes, and whether two layers or one is better, is a matter of trial and error. Using 10 hidden nodes seems to produce a network which is just capable of training on a reasonable-sized factset. I intend to optimise this when I can get a backtestable version working

    ReplyDelete
  3. Hello Everybody,

    For those of you who are interested in generating profits by autotrading FOREX,
    I would like to recommend a unique forex autotrading tool.

    It's called EA Builder and it allows you to create custom Forex Indicators and Trading Strategies.

    The tool includes many features such as:
    * Custom Arrows and Alerts
    * Automated Trading System
    * Trade Just About Anything
    * Alerts
    * Money Management


    GET STARTED: EA Builder

    ReplyDelete