# forex prize forecasting using neural network

Document Sample

```					Price Forecasting Using Neural Networks [ ru ]
Introduction

Preparing Data
To start the operation we should prepare data. The correctness of this work influences 80% of success. Guru of neural networks say, that as entries and exits one should not use the values of quotes Ct. What is really significant is the quotes' changes. While the amplitude of these changes is as a rule smaller than the quotes themselves, there is a strong correlation between the successive quotation values - the most probable quotation value in the next moment will be equal to its previous value C(t+1)=C(t)+delta(C)=C(t).

Meanwhile, for a higher training quality we should aim at a statistic independence of entries, i.e. avoiding such correlations. That is why it is logical to choose as entry variables statistically most independent values, for example quote changes delta(C) or relative increment logarithm log(C(t)/C(t+1)). The last choice is better for long time series, when the influence of inflation is sensible. In such a case simple differences in the parts of the series will have different amplitude, because they are actually valued in different units. And on the contrary, the relations of successive quotes do not depend on the measurement units and will be of the same scale regardless of the inflationary change of measurement units. As a result, the large stationarity of the series enables using for training a large history, thus providing better training. The disadvantage of the immersion into the lag space is the restricted "eyesight" of the net. On the contrary, the technical analysis does not fix a window in the past, and at times uses far series values. For example maximal and minimal series values even in the relatively far past are claimed to have a large impact on the traders' psych, and consequently must be valuable for forecasting. A not wide enough window of the immersion into the lag space is not able to provide such information, which, naturally, lowers the efficiency of forecasting. On the other side, widening the window to such dimensions, when it includes far extreme series values, increases the dimensionality of the net, which results in a worse accuracy of neuronet forecasting. The way out of this seemingly dead-locked situation is alternate methods of coding of the past behavior of the series. Instinctively it is clear, that the the further in the past goes the series history, the less details of its behaviour influences the result of forecasting. It is based on the psychology of the subjective perception of the past by traders, who actually make the future. Consequently, we need to find the presentation of the series dynamics, which would have a selective accuracy: the further in future, the less details, though preserving the general form of the curve. A quite promising tool here can be a wavelet decomposition. In terms of informativity it is equal to the lag immersion, but easier accepts such data compression, which describes the past with the selective accuracy.

Choosing Software
There are different software, intended for working with neural networks. Some of them are more or less universal, others are highly specialized. Here is a short list of some programs: 1. Matlab is a desktop laboratory for mathematic calculations, designing electric circuits and modelling complex systems. It has an built-in programming language and a large set of tools for neural networks - Anfis Editor (education, creating, training and graphic interface), command interface for programming networks, nnTool - for a more precise configuration of a network. 2. Statistica is a powerful software for analyzing data and searching statistic regularities. In this package the work with neuronets is presented in the block STATISTICA Neural Networks (abbreviated, ST Neural Networks, neuro-net packag of the company StatSoft), which is a realization of the whole set of neuronet methods of data analysis. 3. BrainMaker is intended for solving tasks, which yet have no formal methods and algorithms, with incomplete, noisy and contradictory entry data. To such tasks we refer exchanges and financial forecasting, modelling crisis conditions, pattern recognition and others. 4. NeuroShell Day Trader is a neuronet system that meets the specific requirements of traders and is quite easy to use. This program is highly specialized and is intended for trading, though actually is very close to a blackbox. 5. Other programs are less popular. For the primary operation Matlab is quite suitable. We will try to define the fitness of a neuronet for Forex forecasting. The information about MatLab complex can be found in wikipedia at http://en.wikipedia.org/wiki/MATLAB A lot of information about the program is on the web-site http://www.mathworks.com/ You can buy the program at http://www.mathworks.com/store/

Experiment Preparing data
Data is easily acquired using standard tools of MetaTrader: Service -> Quotes archive -> Export As a result we get *.csv file, which is a raw material for preparing data. To transform the file into a convenient for operation *.xls file, import data from *.csv file. For this purpose in excel make the following: Data -> Import external data -> Import data and indicate the prepared primary file. In the import master all the necessary actions are done in 3 steps:

On the third step substitute the separator of the integer and the decimal part by a point, using More... To have data accepted as numbers, not strings, substitute the separator of the integer and the decimal part by a point: Service -> Parameters -> International -> Separator of integer and decimal part. The screenshots show the example of saving opening and closing prices, other data is not needed yet. Now transform all the data in accordance with what we want to forecast. Let us forecast the closing price of the following day upon the four previous ones (the data are presented in five columns, prices are in a chronological order). 1.2605 1.263 1.2641 1.2574 1.2584 1.263 1.2641 1.2574 1.2584 1.2666 1.2641 1.2574 1.2584 1.2666 1.2569 1.2574 1.2584 1.2666 1.2569 1.2506 1.2584 1.2666 1.2569 1.2506 1.2586 1.2666 1.2569 1.2506 1.2586 1.2574

Thanks to easy manipulations in Excel, data is prepared within a couple of minutes. An example of a prepared data file is attached to the article. To have Matlab perceive the files, the prepared data must be saved in *.txt or *. dat files. Let us save them in *.txt files. Then each file should be split - for the net training (selection) and its testing (outside selection). Suchwise prepared euro.zip data are suitable for further operation.

Acquaintance with Matlab
From the command line start the package ANFIS using anfisedit command. The editor consists of four bars - for data (Load data), for net generation (Generate FIS), for training (Train FIS) and for its testing (Test FIS). The upper bar is used for previewing the neuronet structure (ANFIS Info). more information about the package operation is here: http://www.mathworks.com/access/helpdesk/help/toolbox/fuzzy/ To start the operation load data, prepared at the previous stages - clock Load Data and indicate the file with the selection data. Then create a neural network clicking Generate FIS.

For each entry variable set 3 linguistic variables with a triangle reference function. Set a linear function as a function of reference of an exit function.

For neuronet training the package AnfisEdit includes 2 training algorithms - back propagation and a hybrid one. With a hybrid training the net is trained within two-three runs. On a training selection (60 values) after training, the forecast by the net differs from the real one in several points.

But what we need to forecast is future! As the outside-selection data we took the next 9 days after the inside-selection data. On the outside-selection data the mean-square-error made 32 points, which is, of course, unacceptable in the real trading, but it shows that the neuronet direction can be further developed - the game must be worth the candle.

The result of our work is the multilayer hybrid neural network that can forecast absolute price values for the near future. It cardinally changes in its architecture and purposes from a one-layer neural network, described by Y. Reshetov in his article http://articles.mql4.com/ru/289 and realized as an Expert Advisor http://codebase.mql4.com/ru/756. We managed to receive a more or less tolerable forecast on quotes, though neural network experts strongly recommend not to do this. To view the resulting neuronet click Structure. A trained neural network is located in the attached file neuro.zip .

A large advantage of the package Matlab is its integrability with other programs, and there are multiple variants of its integration DDE, comobjects, dll. So, you do not have to create the tool from scratch http://forum.mql4.com/ru/5220, you can use a ready program solution for working with neural networks and genetic algorithms. Then after getting stable forecasting results, you can integrate the neural network into the program MetaTrader through dll.

Conclusion
Neural networks are a very powerful tool for working in financial markets, but learning this technology requires time and effort no less than learning technical analysis. An advantage of neural networks is their objectivity in decision making, their disadvantage - the decisions are actually made by a black box. The main problem that may occur during the work with this technology is connected with the correct pre-processing of data. This stage plays a crucial role in data forecasting and many unsuccessful attempts to work with neural networks are connected with this stage. In order to learn properly networks one has to experiment a lot - but the game is worth the candle. If institutional investors use this tool, then common traders also can try to succeed using trained neural networks, because anything can be input to the network - from indicators and prices till signals of the fundamental analysis.

```
DOCUMENT INFO
Shared By:
Categories:
Tags:
Stats:
 views: 714 posted: 10/13/2009 language: English pages: 8
Description: Mastering forex prize forecasting using neural network