Top Menu

Feedburner

Right-Side Top Menu

Using Recurrent Neural Networks in Forex

April 17, 2013

Today, I present a new e-book for a free download from EarnForex.com. It is Using Recurrent Neural Networks to Forecasting of Forex written by V. V. Kondratenko and Yu. A. Kuperin from the Saint Petersburg State University. This scientific article has been published back in 2003 and was among the first ones to offer some real insight on the capabilities of neural networks to predict foreign exchange rates.

As it often happens with scientific papers written in Eastern Europe or CIS countries, the translation quality in this one is also very low. Despite this fact, the article is not too hard to read as it contains very few formulas and it relies on a small number of math concepts.

The authors use a recurrent neural network composed of 2 input neurons and 1 output neuron with 100 hidden neurons inbetween. Two data sets are used for inputs — raw price rate of change and a moving average with a period set to 5. This input combination proved to be the most effective of several variants they have tried. For the sake of simplicity and prediction usability, moving average one bar ahead is used as the output value. The resulting NN is trained over 1,200 daily bars of EUR/USD, GBP/USD, USD/JPY and USD/CHF. It is then tested on the set of 103 daily bars. The results show a rather significant inclination of the designed neural network to predict both the sign and the size of future currency rate change.

Sadly, the e-book is not without its disadvantages. In addition to the aforementioned translation quality issues, some of the statements look rather funny. As a predominantly weekly trader, I was particularly amused by this quote:

Besides of that, the forecast of weekly data presumes, that trader, who uses this forecast will trade once a week, which is irrelevant from the practical point of view.

Why is it irrelevant? Unfortunately, there is no further explanations given by the authors. I would also like to point out a rather low number of bars used for testing (production set). Increasing it to something comparable to the training set size would be a justified step. The choice of the immediate future moving average value as the NN’s output value looks also suboptimal to me. Actual rate values 5, 10 or 20 bars ahead of the forecast point would be more interesting for practical considerations.

If you have any questions, comments or suggestions regarding this e-book or about adding more free books to EarnForex.com, please feel free to submit them in the comments below.

8 Responses to “Using Recurrent Neural Networks in Forex”

  1. Luca

    I’m trying to replicate a RNN as I’ve seen in this paper for my thesis.

    How could I calculate the predicted close value from the predicted moving average?

    Or how could I get some relevant information from the predicted MA?

    Thanks a lot!

    Luca

    Reply

    Andriy Moraru Reply:

    Calculating close value from a predicted MA value is quite simple actually. Considering 5-period MA. You already have 4 previous close values, so you just add them up and get Csum4 value. Then, calculate the predicted close: 5 × MA – Csum4.

    Reply

  2. Luca

    Thanks Andriy for your reply :)

    Actually the problem is that my predicted moving average is quite similar graphically to real MA (65% to 70% correct prediction of increment or decrement of MA on 4 years).

    But when I transform MA in close value (with your formula) the correct prediction of sign of close value tend to 50%.

    This is MA prediction (prediction red, real blue)

    http://imageshack.com/a/img538/7269/7Od49e.png

    This is the poor close value prediction (prediction red, real close blue)

    http://imageshack.com/a/img538/8063/lFEYpK.png

    Thanks for your help :)

    Reply

    Andriy Moraru Reply:

    Apparently, it means that the method predicts MA disregarding the current Close values. You can have an infinite different sets of Closes that will result in the same MA value.

    So now, I am not really sure if it can help you trade successfully.

    Reply

  3. Vicente Mier

    Hi. I’ve been doing independent attempts to reproduce the experiments from this paper. I kept a journal of my experiments in my blog:

    http://unixforex.blogspot.com/

    A while ago I also wrote an article on a variation I made of Kuperin’s original experiments:

    https://translate.google.com/translate?hl=en&sl=auto&tl=en&u=http%3A%2F%2Fcienciadesatada.blogspot.mx%2F2015%2F04%2Fred-neuronal-recurrente-elman-con.html

    I also have some criticism about the quality of the results shown in the paper. I’ve actually obtained better “R squared” scores by using a trivial prediction method. I describe this method here:

    https://docs.google.com/document/d/1PE2vJcHmYtQNk5GS110QhNYIVHj6k80hiZdO12mv11w/pub

    My trivial prediction method easily outperforms Kuperin’s neural network, when evaluated by the same standards shown in the paper.

    Reply

    Vicente Mier Reply:

    By the way, there’s actually a published Springer article about the exact same method Kondratenko and Kuperin use in theirs. It’s also co-authored by Kuprin. I’ve read the article, and there’s nothing you wouldn’t find in ” Using Recurrent Neural Networks to Forecasting of Forex”. If anything, there are less details:

    http://link.springer.com/chapter/10.1007/3-540-47789-6_127

    Reply

    Andriy Moraru Reply:

    Thanks for sharing your research in such a great detail! That was very insightful reading. I now feel inspired to do some more research into NNs and predicting algorithms. It is also nice to see the code shared – not many developers do that.

    Reply

    Vicente Mier Reply:

    You’re very welcome, Mr. Moraru. I try to follow the 4 freedoms of open-source software. So feel free to download, read, and modify the code.

    I wrote a bunch of C code and bash scripts for this project, but I didn’t comment the source files properly. Si if you have a hard time understanding what’s going on in the code, don’t hesitate to e-mail me with any questions.

    I think Kuperin’s work on financial forecasting using SRNs is very innovative. But because it is so avant-garde, it may come with a few quirks. I tried many different things to try to get it to a point where I could use it to profitably predict market trends. But I believe further research is needed.

    There’s relatively little research being done today on recurrent neural networks, so I think it may be a while before we see any exciting results on the matter. But that’s just my personal opinion.

    Reply

Leave a Reply

required
required (will not be published)
optional

Follow EarnForex Blog on Facebook