Neural Networks in Trading: How to Design a Network for Financial Forecasting in Eight Simple Steps

Let’s be honest, building a neural network for the forecasting of financial series is not an easy task. The success or failure of a network depends on many different aspects and having a way of developing networks which is both systematic and efficient is a very important part of achieving both successful and powerful predictive results.During my “neural networks in trading” series of posts I have faced the incredible challenge of building such networks but have always failed to explain the exact steps necessary  to achieve this goal. On today’s post I will be talking about my approach towards the systematic building and testing of networks which is based on a 1996 article of the Neurocomputing journal written by Kaastra and Boyd on the journal of Neurocomputing (free access here).

First of all I believe that anyone interested in the development of neural networks for the forecasting of financial time series (or the improvement of algorithmic systems) should read this article as it is a great and very slightly technical work which describes the steps necessary to develop networks and the different problems one might find when attempting to implement such a tool. One of the great achievements of this article is that it makes very limited references to mathematics and any particular set of tools, explaining the problems at a very simple level which makes it a very good introduction for anyone interested on this subject but without the need to go too much in-depth into technical matters. Although deeply understanding the way in which neural networks are built and what the different variables of their topology truly implies is key to long term success the understanding of all these parameters might be too complicated to tackle at first and a simple introduction is much more useful for the average trader interested in this field.

I found this article in January 2011 when I was starting to get into neural networks as a part of my yearly objectives in trading. I really liked it because it gave me an overall view of what a trader needs to do when first facing the problem of financial forecasting. For example the article tells us that there are mainly eight steps which need to be tackled in order to go from the idea of implementing a network to the full practical implementation. The first step suggested by the authors -“variable selection” – is probably the most important as it determines the whole nature of the problem as within this step you select the variables you want to study amongst all those available within the financial series. For example this is where I decide that I want to forecast the GBP/USD weekly close or the XAU/USD monthly volatility (to give some examples).

The next two steps, data collection and preprocessing, deal with the collection of data relevant to the above variables and the processing of this data to make it pallatable for the neural network. For example if I wanted to forecast the GBP/USD weekly close I would collect all GBP/USD weekly closing data and other data I think might be relevant for this predicition (for example GBP/USD high, low and open values and all OHLC data for the EUR/USD. After this I then need to preprocess this data to both highlight the relationships I want to forecast for the network and scale it to the network’s prefered 1 to 10 range. For example by dividing all values by the GBP/USD close and then dividing them by 10 I get values between 0 and 1 which already have some pre-drawn relationships that tie them to the GBP/USD close. Networks are not very good at drawing relationships from pure data (for example OHLC data) but you need to build some relationships between data in the preprocessing steps to gain a better chance at success.

Step number four – training, testing and validation set selection- deals with the division of the above data in order to test the network implementation on later steps. For example if I had I a year of data I may wish to train for the first 4 months, then test the results for the next 2 months and retrain if necessary and then finally test over the whole year for validation. However this notion has been pretty much deprecated since the creation of this article as now the most robust form of evaluation – which is the one I used for Asirikuy NN developments- includes the introduction of a moving window which constantly changes the training period automatically and performs constant validation through a very long period of time (for example a 10 year period).

The next steps 5-7 deal with the evaluation of what we would call “network topology”. Within these steps the user should evaluate the structure of the network, the evaluation criteria (what determines the network’s success or failure) and training procedure (number of iterations, learning rate, etc). The article is especially useful here as it gives us some very important tips regarding how to build a network for financial forecasting. For example we are discouraged to choose more than 2 hidden layers and we are also given several tips on how to choose the number of hidden neurons and the effect that changing these parameters might have on our end result. Certainly these steps are the ones which might take the builder of the network the most time as they encompass the largest amount of possible choices and it is often difficult – needing substantial experience – to build a network which has reached an optimum in this regard. Often extensive testing through moving window out-of-sample type testing is needed to reach something which has a high level of usefulness. Bear in mind however that initially all you’re required to make is some choice regarding network structure which later on (after testing and implementation) can be changed.

The last step of the development process –  implementation – is a very important one as it will determine the global capabilities of your NN implementation. The software you use will often determine the flexibility of your implementation and therefore how many options you can use to improve on your first selections. For my Asirikuy NN programs I have used FreePascal and FANN as they provide a very easy way to build networks and interface them with expert advisors coded on the MQL4 language. Additionally DLLs generated from this “combo” can be used on any other type of trading system  (coded on MQL5, C++, etc) giving us a lot of flexibility regarding where and how we can use the neural network. This combo also allows us to create iteratively optimizing neural networks that use a moving window approach on the MT4 backtester.

So if you want to build neural networks for the forecasting of financial time series I definitely encourage your to read the above mentioned article :o) If you would like to learn more about my work in trading and how you too can learn more about the power and coding of neural networks 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
You can leave a response, or trackback from your own site.

2 Responses to “Neural Networks in Trading: How to Design a Network for Financial Forecasting in Eight Simple Steps”

  1. Franco says:

    Daniel, Thanks for the article…

Leave a Reply

Subscribe to RSS Feed Follow me on Twitter!
Show Buttons
Hide Buttons