Forex Blog

First-hand Forex trading experience and information about foreign exchange market that will be useful to traders


Using Recurrent Neural Networks in Forex

April 17, 2013 by

Today, I present a new e-book for a free download from 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, please feel free to submit them in the comments below.

14 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!



    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.


  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)

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

    Thanks for your help :)


    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.


  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:

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

    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:

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


    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:


    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.


    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.


  4. Sebastian

    Kuperin states that he can predict approx 80% of the increment signs. Isn’t that enough for profitable trading?


    Andriy Moraru Reply:

    Depends on what kind of increment signs he can predict. If that’s 80% chance of gaining 1 point vs. 20% chance of losing 5 points, it is not profitable.


  5. Vicente Mier

    As it turns out, predicting increment signs with 80% accuracy is not all that hard.

    I’d suggest you try the following experiment:

    Take any currency exchange rate history dataset and take a few subsets from it. Now, perform the following trivial prediction algorithm on those subsets:

    For each increment sign in the subset, predict that it will have the same direction as the previous increment sign.

    You’ll notice that just out of sheer luck, some (many) of your subsets will turn out to have 80% correct predictions.

    Kuperin’s neural network uses one exchange rate value from a previous day to predict the value from the day next to it. Their neural network might as well just be spitting out predictions with a value close to the value from the previous day (from it’s input). This should be enough to produce an 80% hit rate for some data subsets.

    Kuperin et al only tried their algorithm with very few subsets. Perhaps they did something like the experiment I suggested here, and cherry-picked the sub-sets more likely to produce favorable R-squared and increment sign hit ratios, so that the numbers would look good on paper.


  6. Vicente Mier

    Just to reiterate: I myself have performed this experiment. I haven’t tested it for the increment signs. But I have for the R-squared results. It turns out that a lot of subsets show an R-squared greater than 0.6 (which is the best that Kuperin et al got), when using my trivial prediction method:


  7. Vicente Mier

    Sorry: the best they get is something around 0.69. Well: I get up to 0.74, and I don’t even use a neural network. I just predict: “Tomorrow’s value will be the exact same as today” on a bunch of data subsets, and my R-squared results range from 0.3 to 0.74.

    It would be interesting to see what their neural network gets when tested against a dataset where my trivial method gets a low R-squared score, such as 0.3. I would suspect that their neural network won’t get anything much higher. If any.

    Of course, Kuperin et al did not share any code or datasets. So I guess we’ll be left wondering.


  8. Vicente Mier

    Oh, and one more thing: Kuperin doesn’t predict the increment sign for the exchange rate itself, but for the Moving Average of the logarithmic Return Rate.

    That makes it even MORE likely that the increment sign of the previous day be the same as the sign for the next day, because the moving average actually Smoothens the return rate fluctuations.


Leave a Reply

required (will not be published)