Hybrid Forex Prediction Model Using Multiple Regression, Simulated Annealing, Reinforcement Learning and Technical Analysis
Hybrid Forex Prediction Model Using Multiple Regression, Simulated Annealing, Reinforcement Learning and Technical Analysis
Corresponding Author:
Hana Jamali
Computer and System Engineering Laboratory, Faculty of Science and Technology, Cadi Ayyad University
Marrakesh, Morocco
Email: [email protected]
1. INTRODUCTION
Currency is an indispensable tool in the economy of the countries. It derives its importance from
being: i) used as a reserve currency by central banks, ii) used as an invoicing currency for international
transactions, and iii) used as a vehicle currency for currency transactions. Vehicle currencies are used when
the transaction cost of trading two currencies directly is higher than the cost of trading them indirectly, via two
transactions through the vehicle currency [1].
Forex is the market in which so-called convertible currencies (currency pairs) are traded against each
other at constantly changing exchange rates, allowing it to be the most liquid market and the largest after the
debt. This global market has no borders and is physically located in no particular place. At any time, an identical
transaction can be carried out simultaneously in Paris, London, Zurich, Hong Kong or New York. Indeed,
trading volumes on Forex have been growing steadily since the 2000s.
The daily trading volume in 2019 on Forex reached 5,345 billion dollars, a 24% increase in volumes
compared to the daily transaction volume recorded, in 2013 according to the latest figures published by the
Banks of International Settlements (BIS). By comparison, France's gross domestic product (GDP) was $2,716
billion and Japan's $5,065 billion in 2019. It has traded in a day on Forex more than the annual GDP of Japan.
This makes it by far the biggest financial market in the world, far ahead of the equity markets (tiny compared
to Forex).
Forex is an over-the-counter market where the transaction is concluded directly between two
counterparties, the seller and the buyer. In other words, the transaction of purchase or sale of the currency is
made in a consensual manner between the seller and the buyer of the currency, it is an action in which only the
free will is considered. Characterized by intermediation and significant bid-ask spreads/intermediation fees [2],
[3]. Given its large transactions, Forex becomes one of the most followed markets by economic players and
institutional operators and individuals, this feature makes it a market sensitive to any economic influence, such
as budget deficits of western nations, their recovery plans, and the monetary policies of the central banks of
the world's largest powers.
Previously, when the internet was not accessible to all, only the major players in the market, such as
international banks and major financial centers, could participate in trading and currency speculation. By cons
currently, following the technological development and internet revolution, speculation and Forex trading can
be done by any major person able to trade. Trading in the Forex market requires huge capital investments. In
fact, it depends on the trading strategy you choose. So, in Forex trading, it is possible to invest sums greater
than the initial deposit thanks to the leverage, but the losses cannot exceed the balance of the account, Forex
brokers lend money to traders for that they can increase their investments in the foreign exchange market.
Leverage is there for essentially about borrowing money from a broker to increase the return on investment.
However, it also means that the trader increases the risk of losing more money. Leverage is partly responsible
for the popularity of Forex trading, as traders can easily choose the risk they want to take with a reduced capital
contribution.
The most popular currencies in the world and the most traded in Forex are the US dollar (USD), the
euro (EUR), the pound sterling (GBP), the Japanese yen (YEN) and the Swiss Franc (CHF). These currencies
make up a group of major currency pairs containing EURUSD, GBPUSD, USDJPY, USDCHF, GBPJPY,
EURGBP, EURCHF [3]; Figure 1 represents the exchange rates of the major currencies from Tuesday
February, 05 2019 at 15:13 UTC (universal time coordinated). These major pairs are characterized by lower
spreads and higher trading volume relative to other currencies.
In order to put the odds on their side, traders need to accurately predict the exchange rate at any given
time. Making a short term Forex market forecast is not an easy thing, even winning in Forex is not available
every time, but the trader can use a short term investment strategy to improve these trading decisions. In this
article, we will adopt the following plan, in the first section we will make a state of the art on the most used
techniques and investment strategies on Forex, the second section will be used to propose a short-term
investment strategy term on Forex, then the third section will be dedicated to drawing a general conclusion and
discussing the prospects envisaged.
Figure 1. The exchange rates of the major currencies from tuesday February 05 th, 2019 at 15:13 UTC
Hybrid Forex prediction model using multiple regression, simulated annealing … (Hana Jamali)
894 ISSN: 2252-8938
that the behavior of past achievements will recur in the future. In this study the method adopted is the
quantitative method, because we have a database containing the exchange rates of the EUR/USD pair.
3. PROPOSED SYSTEM
Following the most of conclusions reached from the bibliographic research, the combination of two
or more techniques can show better results [8], [9], [21] in terms of the exchange rate prediction accuracy, the
proposed model in this paper combines more than one method to predict exchange rates:
− Multiple regression for its ability to determine the relative influence of one or more predictor variables on
the value of the criterion.
− Simulated annealing to avoid getting locking in a local optimum.
− In order to structure efficient trading systems, RL has enormous capacities in terms of decision-making
using an intelligent agent.
− The RSI technical indicator assesses overbought or oversold conditions of the exchange rate.
Hybrid Forex prediction model using multiple regression, simulated annealing … (Hana Jamali)
896 ISSN: 2252-8938
almost 1,227 records, we chose the EUR/USD pair because it has around 25% trading volume in Forex, which
makes it ideal for short term prediction. The dataset contains the daily values of the open, close, high and low
prices. The period 2016-2020 was chosen because it was characterized by several world events having
influenced the Forex market, in particular, the election of Trump as president of the United States of America
for the presidential term 2017-2021 with all with all his decisions that havig marked the Americain economy
and consequently the world economy, thus this period was marked by the health crisis linked to the coronavirus
disease 2019 (COVID 19) pandemic with the restrictions that this entails, such as the contraction of the
economy and per capita income, which will tilt millions of people into extreme poverty. The dataset used is
separated into two parts, the training set 80% and the testing set 20%, The literature review revealed that the
testing or the validation set should be approximately from one fourth to one eight of the training set [23].
4. MODEL TECHNIQUES
4.1. Multiple regression
Multiple regressions are a family of statistics used to investigate the relationship between a set of
predictors and a criterion (dependent) variable. This procedure is applicable in a variety of research contexts
and data structures [10], [24]–[27]. This is the case in the model proposed by this study. The implementation
of the regression algorithm in this model is started by the use of the values of the exchange rates of days D,
D-1, D-2, D-3, D-4, D-5, D-6, the average of last two weeks and the average of the last month, as input values.
One of the advantages of multiple regression is the ability to determine the relative influence of one
or more predictor variables on the value of the criterion, also its simplicity of interpretation and its ease of
calculation. Figures 4 to12 illustrate a shift between the predicted values and the real values of exchange rates,
this shift widens as the prediction day moves away from day D, this shift is clearly represented by the
calculation of the coefficient of determination R² which makes it possible to measure the adequacy between
the real values and the predicted values. Figure 13 represents the coefficient of determination calculated for
the predicted days. The prediction of the exchange rate values using multiple regression method shows a high
accuracy of more than 99% for day D, but on the other hand, this precision decreases for day D+1 until day
D+14. In this case, we propose to integrate an optimization solution such as simulated annealing meta-heuristic
to adjust the predicted values with the real values.
Hybrid Forex prediction model using multiple regression, simulated annealing … (Hana Jamali)
898 ISSN: 2252-8938
Figure 4. Comparison of the test set predictions of day D got by multiple regression (red line) with real
output values (blue line)
Figure 5. Comparison of the test set predictions of day D+1 got by multiple regression (red line) with real
output values (blue line)
Figure 6. Comparison of the test set predictions of day D+2 got by multiple regression (red line) with real
output values (blue line)
Figure 7. Comparison of the test set predictions of day D+3 got by multiple regression (red line) with real
output values (blue line)
Figure 8. Comparison of the test set predictions of day D+4 got by multiple regression (red line) with real
output values (blue line)
Figure 9. Comparison of the test set predictions of day D+5 got by multiple regression (red line) with real
output values (blue line)
Hybrid Forex prediction model using multiple regression, simulated annealing … (Hana Jamali)
900 ISSN: 2252-8938
Figure 10. Comparison of the test set predictions of day D+6 got by multiple regression (red line) with real
output values (blue line)
Figure 11. Comparison of the test set predictions of day D+7 got by multiple regression (red line) with real
output values (blue line)
Figure 12. Comparison of the test set predictions of day D+14 got by multiple regression (red line) with real
output values (blue line)
Figure 13. Multiple R-squared calculated between real values and predicted values
Hybrid Forex prediction model using multiple regression, simulated annealing … (Hana Jamali)
902 ISSN: 2252-8938
Figure 15. Comparison of the test set optimized predictions of day D got by Simulated annealing (red line)
with real output values (blue line)
Figure 16. Comparison of the test set optimized predictions of day D+1 got by Simulated annealing (red line)
with real output values (blue line)
Figure 17. Comparison of the test set optimized predictions of day D+2 got by simulated annealing (red line)
with real output values (blue line)
Figure 18. Comparison of the test set optimized predictions of day D+3 got by Simulated annealing (red line)
with real output values (blue line)
Figure 19. Comparison of the test set optimized predictions of day D+4 got by Simulated annealing (red line)
with real output values (blue line)
Figure 20. Comparison of the test set optimized predictions of day D+5 got by Simulated annealing (red line)
with real output values (blue line)
Hybrid Forex prediction model using multiple regression, simulated annealing … (Hana Jamali)
904 ISSN: 2252-8938
Figure 21. Comparison of the test set optimized predictions of day D+6 got by Simulated annealing (red line)
with real output values (blue line)
Figure 22. Comparison of the test set optimized predictions of day D+7 got by Simulated annealing (red line)
with real output values (blue line)
Figure 23. Comparison of the test set optimized predictions of day D+14 got by Simulated annealing (red
line) with real output values (blue line)
Table 1. Comparaison of MSE obtained by using multiple regression and simulated annealing
Day MSE
With multiple regression With multiple regression and simulated annealing
D 0.0000204076 0.00002029581
D+1 0.00004046837 0.00004036597
D+2 0.00006178088 0.0000616916
D+3 0.00008198048 0.00008193095
D+4 0.00008193095 0.0001014745
D+5 0.0001205481 0.0001205404
D+6 0.0001393285 0.0001390773
D+7 0.0001567872 0.0001561272
D+14 0.000254101 0.0002530860
Stimulus⟶Response⟶Consequence
Thorndike postulates the existence of learning laws. On one hand,the law of exercise states that the
link between stimulus and response is strengthened by exercise and that the probability of response increases
with the number of trials performed. On the other hand, the law of effect states that the link between the
stimulus and the response is strengthened or weakened by the immediate effect of its consequences.
RL is different from supervised learning because it does not need inputs and outputs to learn, it is the
agent who decides what to do in a specific situation. so, in the proposed model, the environment is the Forex
market, the stocks are buy, sell and hold, the state is represented by the exchange rates predicted by the
combination of the multiple regression algorithm and the metaheuristic of simulated annealing (outputs from
block 3). Figures 24 to 32 represent the initial decisions obtained based on the predictions of the exchange rates
for days D, D+1, D+2, D+3, D+4, D+5, D+6, D+ 7, D+14. Also the model proposes to calculate the total gains
and the percentage of investment according to the predictions obtained, Table 2 and Table 3 present the results
for an investment of €10,000 and €50,000.
Figure 24. Day D buying signal and selling signal using reinforcement learning
Hybrid Forex prediction model using multiple regression, simulated annealing … (Hana Jamali)
906 ISSN: 2252-8938
Figure 25. Day D+1 buying signal and selling signal using reinforcement learning
Figure 26. Day D+2 buying signal and selling signalusing reinforcement learning
Figure 27. Day D+3 buying signal and selling signal using reinforcement learning
Figure 28. Day D+4 buying signal and selling signal using reinforcement learning
Figure 29. Day D+5 buying signal and selling signal using reinforcement learning
Figure 30. Day D+6 buying signal and selling signal using reinforcement learning
Hybrid Forex prediction model using multiple regression, simulated annealing … (Hana Jamali)
908 ISSN: 2252-8938
Figure 31. Day D+7 buying signal and selling signal using reinforcement learning
Figure 32. Day D+14 buying signal and selling signal using reinforcement learning
5. CONCLUSION
This paper represents the continuity of a previously published work of a model proposed to combine
two techniques which are: multiple regression and simulated annealing, the results showed that the combination
of two techniques gives good precision of prediction. From this conclusion, we proposed an improvement of
the model through the introduction of new techniques which are learning by reinforcement and RSI indicator.
All about harnessing the strengths of these techniques to refine investment decision-making, which must be
made based on the combination of the four techniques. It must be proven that the purpose of this model is not
only to maximize investment profits for traders, but also to limit the risks associated with the prediction and
this through the multitude and diversity of techniques used in terms of type to reassure better prediction
compared to using a single technique, we used supervised learning, meta heuristics, RL and technical analysis.
As a future work and following the current political and economic situation which is characterized by its
disturbed and non-stationary nature, we aim to extend the application domain of this model to contain the oil
market to predict the daily movements of this marketand analyze its influence on the global economy.
Hybrid Forex prediction model using multiple regression, simulated annealing … (Hana Jamali)
910 ISSN: 2252-8938
REFERENCES
[1] R. K. Lyons, “New perspective on FX markets: order-flow analysis,” International Finance, vol. 4, no. 2, pp. 303–320, Jul. 2001,
doi: 10.1111/1468-2362.00075.
[2] A. Geromichalos and K. M. Jung, “An over-the-counter approach to the Forex market,” International Economic Review, vol. 59,
no. 2, pp. 859–905, 2018, doi: 10.1111/iere.12290.
[3] R. K. others Lyons, The microstructure approach to exchange rates. Citeseer, 2001.
[4] S. Achchab, O. Bencharef, and A. Ouaarab, “A combination of regression techniques and cuckoo search algorithm for FOREX
speculation,” in World Conference on Information Systems and Technologies, 2017, vol. 569, pp. 226–235, doi: 10.1007/978-3-
319-56535-4_23.
[5] C. Evans, K. Pappas, and F. Xhafa, “Utilizing artificial neural networks and genetic algorithms to build an algo-trading model for
intra-day foreign exchange speculation,” Mathematical and Computer Modelling, vol. 58, no. 5–6, pp. 1249–1266, 2013,
doi: 10.1016/j.mcm.2013.02.002.
[6] L. Mendes, P. Godinho, and J. Dias, “A Forex trading system based on a genetic algorithm,” Journal of Heuristics, vol. 18, no. 4,
pp. 627–656, 2012, doi: 10.1007/s10732-012-9201-y.
[7] M. A. H. Dempster and Y. S. Romahi, “Intraday FX trading: an evolutionary reinforcement learning approach,” in International
Conference on Intelligent Data Engineering and Automated Learning, Springer Berlin Heidelberg, 2002, pp. 347–358.
[8] F. Rundo, “Deep LSTM with reinforcement learning layer for financial trend prediction in FX high frequency trading systems,”
Applied Sciences (Switzerland), vol. 9, no. 20, p. 4460, 2019, doi: 10.3390/app9204460.
[9] H. Jamali, O. Bencharef, A. Nabaji, K. El Housni, and Z. Asebriy, “Improving regression models using simulated annealing for
stock market speculation,” in World Conference on Information Systems and Technologies, 2018, vol. 745, pp. 295–304,
doi: 10.1007/978-3-319-77703-0_30.
[10] O. Chantarakasemchit, S. Nuchitprasitchai, and Y. Nilsiam, “Forex rates prediction on EUR/USD with simple moving average
technique and financial factors,” in 17th International Conference on Electrical Engineering/Electronics, Computer,
Telecommunications and Information Technology, ECTI-CON 2020, 2020, pp. 771–774, doi: 10.1109/ECTI-
CON49241.2020.9157907.
[11] M. A. H. Dempster, T. W. Payne, Y. Romahi, and G. W. P. Thompson, “Computational learning techniques for intraday FX trading
using popular technical indicators,” IEEE Transactions on Neural Networks, vol. 12, no. 4, pp. 744–754, Jul. 2001,
doi: 10.1109/72.935088.
[12] A. V. Rutkauskas, A. Miečinskiene, and V. Stasytyte, “Investment decisions modelling along sustainable development concept on
financial markets,” Technological and Economic Development of Economy, vol. 14, no. 3, pp. 417–427, Sep. 2008,
doi: 10.3846/1392-8619.2008.14.417-427.
[13] Y. L. Yong, D. C. L. Ngo, and Y. Lee, “Technical indicators for Forex forecasting: a preliminary study,” in International Conference
in Swarm Intelligence, 2015, vol. 9142, pp. 87–97, doi: 10.1007/978-3-319-20469-7_11.
[14] Y. Chihab, Z. Bousbaa, M. Chihab, O. Bencharef, and S. Ziti, “Algo-trading strategy for intraweek foreign exchange speculation
based on random forest and probit regression,” Applied Computational Intelligence and Soft Computing, vol. 2019, 2019,
doi: 10.1155/2019/8342461.
[15] B. Omar, G. C. Daniel, B. Zineb, and C. J. Aida, “A comparative study of machine learning algorithms for financial data prediction,”
in International Symposium on Advanced Electrical and Communication Technologies, ISAECT 2018 - Proceedings, Nov. 2018,
pp. 1–5, doi: 10.1109/ISAECT.2018.8618774.
[16] P. H. Damia Abd Samad, S. Mutalib, and S. Abdul-Rahman, “Analytics of stock market prices based on machine learning
algorithms,” Indonesian Journal of Electrical Engineering and Computer Science, vol. 16, no. 2, pp. 1050–1058, 2019,
doi: 10.11591/ijeecs.v16.i2.pp1050-1058.
[17] D. A. Fattah, A. A. Naim, A. S. Desuky, and M. S. Zaki, “AutoKeras and particle swarm optimization to predict the price trend of
stock exchange,” Bulletin of Electrical Engineering and Informatics, vol. 11, no. 2, pp. 1100–1109, 2022, doi: 10.11591/eei.v11i2.3373.
[18] R. Rassetiadi and Suharjito, “Foreign exchange prediction based on indices and commodities price using convolutional neural
network,” Indonesian Journal of Electrical Engineering and Computer Science, vol. 18, no. 1, pp. 494–501, Apr. 2019,
doi: 10.11591/ijeecs.v18.i1.pp494-501.
[19] M. Khushi and T. L. Meng, “Reinforcement learning in financial markets,” Data, vol. 4, no. 3, p. 110, 2019,
doi: 10.3390/data4030110.
[20] J. Carapuço, R. Neves, and N. Horta, “Reinforcement learning applied to Forex trading,” Applied Soft Computing Journal, vol. 73,
pp. 783–794, 2018, doi: 10.1016/j.asoc.2018.09.017.
[21] B. Jubert de Almeida, R. Ferreira Neves, and N. Horta, “Combining support vector machine with genetic algorithms to optimize
investments in Forex markets with high leverage,” Applied Soft Computing Journal, vol. 64, pp. 596–613, Mar. 2018,
doi: 10.1016/j.asoc.2017.12.047.
[22] “EA Trading Academy - online courses | strategy builders | expert advisors,” Trading Academy. https://eatradingacademy.com/
(accessed Oct. 25, 2016).
[23] R. Pardo, Design, testing, and optimization of trading systems, vol. 2. John wiley & Sons, 1992.
[24] J. F. Hair, Multivariate data analysis, 7th edision Prentice Hall International, 2010.
[25] L. Plonsky, Advancing quantitative methods in second language research. Routledge New York: Routledge New York, 2015.
[26] L. Plonsky and H. Ghanbar, “Multiple regression in L2 research: a methodological synthesis and guide to interpreting R2 values,”
Modern Language Journal, vol. 102, no. 4, pp. 713–731, Dec. 2018, doi: 10.1111/modl.12509.
[27] B. G. Tabachnick, L. S. Fidell, and J. B. Ullman, Using multivariate statistics, 6th edision vol. 5. pearson Boston, MA, 2007.
[28] S. Kirkpatrick, C. D. Gelatt, and M. P. Vecchi, “Optimization by simulated annealing,” Science, vol. 220, no. 4598, pp. 671–680,
May 1983, doi: 10.1126/science.220.4598.671.
[29] L. Thorndike and D. Bruce, Animal intelligence: experimental studies. Routledge, 2017.
BIOGRAPHIES OF AUTHORS
Dr. Younes Chihab He received the doctorate thesis in Network Security from
the Faculty of Sciences in the Cadi Ayyad University, Marrakech, Morocco, in December
2013. His research was in artificial intelligence, signal processing and machine learning. In
2019, he received the PHD degree in Computer Sciences from the Faculty of Sciences, Ibn
Tofail University, Kenitra, Morocco. His research interests include the signal and image
processing and coding, networking and artificial intelligence. Actually, he is a professor and
member of the Computer Sciences Research Laboratory (CSRL), Superior School of
Technology, Ibn Tofail University, Kenitra, Morocco. He can be contacted at email:
[email protected].
Dr. Omar Bencharef received the D.Sc. degree (Doctor Habilitatus D.Sc.) in
computer science from the Faculty of Sciences and Technology, Cadi Ayyad University,
Marrakech, Morocco, in April 2018. He is a Professor of Computer Science in the Faculty
of Sciences and Technology, Cadi Ayyad University, since 2013. His research interests
include the signal and image processing and coding, networking and artificial intelligence.
He can be contacted at email: [email protected].
Hybrid Forex prediction model using multiple regression, simulated annealing … (Hana Jamali)