Optimizing Long Short-Term Memory to Predict Currency Rates

  • Yarham Syahabi Lubis King Abdulaziz University, Jeddah
  • Muhammad Rizqy Septyandy Mulawarman University, Samarinda
  • Mika Debora Br Barus Samarinda State Agricultural Polytechnic, Samarinda
Abstract views: 223 , PDF downloads: 186
Keywords: Machine Learning, Prediction, Time Series, Currency Rates, Long Short-Term Memory, Saudi Arabia


As a travel destination, Saudi Arabia attracts individuals worldwide, including tourists, investors, and immigrant workers, for various purposes, including trip planning, investment decisions, and remittance transfers. Indonesia and Pakistan are the biggest countries that send Umrah and Hajj pilgrims. We need to predict currency rates in 3 pairs of currencies that are frequently used by travel agencies, Hajj and Umrah pilgrims, such as the Saudi Riyal (SAR) against the Pakistani Rupee, the SAR against the Indonesian Rupiah (IDR), and the United States Dollar (USD) against the IDR. This study utilizes Long Short-Term Memory (LSTM) models, the machine learning approach for predicting currency pairs exchange rates. Previous studies succeeded in predicting USD/IDR rates using the LSTM time series-machine learning approach, but the root mean square error (RMSE) value was the worst 271. The research aims to optimize the LSTM to predict the currency rate in the future using historical data obtained from investing.com. We use Python to predict the currency rate pairs, following an experimental investigation with adjustments to the batch size, epoch, and prediction days. The experimental results show that SAR/PKR has a smaller mean square error (MSE) of 0.94, RMSE of 0.97, and MAE of 0.61, while SAR/IDR and USD/IDR Excel with Models 2 and 1 have smaller MSEs of 317.79 and 6654.41, RMSEs of 17.82 and 81.57, and MAEs of 10.54 and 50.12, respectively.


Download data is not yet available.


Islamic Landmarks. "Hajj quota 2023: Hajj pilgrimage quotas for countries around the world: Islamic landmarks." Available at: (https://www.islamiclandmarks.com/makkah-hajj-places/hajj-quota). Accessed November 8, 2023.

Investopedia. "Exchange Rates: What They Are, How They Work, Why They Fluctuate." Available at: (https://www.investopedia.com/terms/e/exchangerate.asp). Accessed November 8, 2023.

Permana, D., & Fitri, I. A. "Application of Fuzzy Time Series-Markov Chain Method in Forecasting Data of Exchange Rate Riyal-Rupiah." Journal of Physics: Conference Series, 1554, 012005*, 2020. [doi:10.1088/1742-6596/1554/1/012005].

Zahroh, S., Hidayat, Y., Septiani, R., Jiwani, R., Jiwani, N.M., Supartini, E., Sukono. "Indonesian Rupiah Exchange Rate in Facing COVID-19 (A Time Series-Machine Learning Approach)." Journal of Advanced Research in Dynamical & Control Systems, Vol. 12, Issue-06*, 2020.

Qu, Y., & Zhao, X. "Application of LSTM Neural Network in Forecasting Foreign Exchange Price." Journal of Physics: Conf. Series 1237, 2019. doi:10.1088/1742-6596/1237/4/042036.

Echrigui, R., & Hamiche, M. "Optimizing LSTM Models for EUR/USD Prediction in the Context of Reducing Energy Consumption: An Analysis of Mean Squared Error, Mean Absolute Error, and R-Squared." E3S Web of Conferences (Vol. 412, p. 01069), ICIES'11 2023. doi:10.1051/e3sconf/202341201069.

Zahrah, H.H., Sa'adah, S., Rismala, R. "Foreign Exchange Rate Prediction Using Long-Short Term Memory: A Case Study in COVID-19 Pandemic." International Journal on ICT, 6(2), 94-105, 2020. doi:10.21108/IJOICT.2020.62.538.

Wijesinghe, S. "Time series forecasting: analysis of LSTM neural networks to predict exchange rates of currencies." Instrumentation (Vol. 7, No. 4), December 2020.

Yadav, A., Jha, C. K, Sharan, A. "Optimizing LSTM for time series prediction in Indian stock market." Procedia Computer Science, Volume 167, Pages 2091-2100, 2020. doi:10.1016/j.procs.2020.03.257.

Sun, R. "Research on Prediction Model of US Stock Index Price Trend Based on LSTM Neural Network." D.Capital University of Economics and Trade, 2015.

Rabbi, MF et al. "Foreign currency exchange rate prediction using long short-term memory, support vector regression and random forest regression." Financial Data Analytics, pp. 251–267. Available at: https://doi.org/10.1007/978-3-030-83799-0_8, 2022.

Yıldırım, D. C., Toroslu, I. H., & Fiore, U. "Forecasting directional movement of Forex data using LSTM with technical and macroeconomic indicators." Financial Innovation, pp.1-36. doi:10.1186/s40854-020-00220-2, 2021.

Otten, N.V. "How To Apply Feature Scaling In Machine Learning [Top Methods & Tutorials In Python]." Spot Intelligence, https://spotintelligence.com/2023/07/31/feature-scaling-machine-learning/. Accessed November 24, 2023.

Lundin M, Lundin J, et al. "Artificial neural networks applied to survival prediction in breast cancer." Oncology, 57(4):281-6, 1999.

Colah's blog. "Understanding LSTM Networks." Available at: https://colah.github.io/posts/2015-08-Understanding-LSTMs/. Accessed November 8, 2023.

Gaurav, S. "Breast Cancer Prediction Using Machine Learning." International Journal of Scientific Research in Computer Science, Engineering and Information Technology (IJSRCSEIT), ISSN : 2456-3307, Volume 6 Issue 4, pp. 278-284, July-August 2020.

Deepchecks Glossary. "Mean Absolute Error." Available at: https://deepchecks.com/glossary/mean-absolute-error/. Accessed November 8, 2023.

R-squared. "Corporate Finance Institute." Available at: https://corporatefinanceinstitute.com/resources/data-science/r-squared/. Accessed November 8, 2023.

Sartono, A. Financial Management. Yogyakarta: BPFE, 2001.

How to Cite
Lubis, Y. S., Rizqy Septyandy, M., & Debora Br Barus, M. (2023). Optimizing Long Short-Term Memory to Predict Currency Rates. International Journal of Artificial Intelligence & Robotics (IJAIR), 5(2), 71-80. https://doi.org/10.25139/ijair.v5i2.7318