Harnessing Machine Learning for Stock Price Prediction with Random Forest and Simple Moving Average Techniques

Authors

  • Arif Mudi Priyatno University of Pahlawan Tuanku Tambusai
  • Lidya Ningsih Telkom University, Jawa Barat, Indonesia
  • Muhammad Noor School of Computing, Univeriti Utara Malaysia, Kedah, Malaysia

DOI:

https://doi.org/10.69693/jesa.v1i1.1

Keywords:

Machine Learning, Stock Price, Random Forest, Simple Moving Average, Prediction

Abstract

This paper explores the application of machine learning in predicting stock price trends, specifically for PT Bank Central Asia Tbk (BBCA) shares, using the Random Forest Regression model and Simple Moving Average (SMA) techniques. The SMA parameters ranged from 3 to 200 days, aiding in forecasting the price trends as either rising, sideway, or declining. To achieve accurate and generalizable predictions, the data normalization process was implemented using the MinMax scaler. The methodological framework adopted a time series cross-validation (CV) approach, executed 10 times with a future test window of 40 days, ensuring the robustness and reliability of the predictive model. The model's performance was systematically evaluated based on metrics of accuracy, recall, precision, and F1-score. Results from the cross-validation series indicated varied performance, with the most notable achievements in the 9th and 10th iterations, where both demonstrated an F1-score surpassing 0.745 and 0.808 respectively, and similar levels of accuracy and recall at 0.825. These high F1-scores signify a strong harmonic balance between precision and recall, underscoring the model's capability to effectively predict the stock price movements of BBCA. The findings affirm the potential of utilizing advanced machine learning techniques like Random Forest in conjunction with SMA indicators to enhance the predictability of stock market trends, offering valuable insights for investors and financial analysts.

Downloads

Download data is not yet available.

References

A. B and M. Deo, “The Influence of Macroeconomic Variables on the Stock Market Performance,” SSRN Electron. J., vol. 1, no. 1, pp. 1–15, Jun. 2021, doi: 10.2139/ssrn.4089305.

M.-P. Leonardo, C.-M. Carlos Eduardo, T.-H. Ana María, T.-G. José Luis, and L.-R. Campo Elias, “Formalization of a new stock trend prediction methodology based on the sector price book value for the Colombian market,” Heliyon, vol. 8, no. 4, p. e09210, Apr. 2022, doi: 10.1016/j.heliyon.2022.e09210.

A. M. Rahmani, B. Rezazadeh, M. Haghparast, W.-C. Chang, and S. G. Ting, “Applications of Artificial Intelligence in the Economy, Including Applications in Stock Trading, Market Analysis, and Risk Management,” IEEE Access, vol. 11, pp. 80769–80793, 2023, doi: 10.1109/ACCESS.2023.3300036.

R. Regulagadda, V. Veeraiah, G. Muthugurunathan, L. N. K. S. Madupu, S. V Satyanarayana, and E. Muniyandy, “Predictive Analytics in Stock Markets: Unleashing the Power of IoT and Machine Learning,” Int. J. Intell. Syst. Appl. Eng., vol. 12, no. 12s, pp. 414–422, 2024.

A. Thakkar and K. Chaudhari, “Fusion in stock market prediction: A decade survey on the necessity, recent developments, and potential future directions,” Inf. Fusion, vol. 65, no. July 2020, pp. 95–107, Jan. 2021, doi: 10.1016/j.inffus.2020.08.019.

I. K. Nti, A. F. Adekoya, and B. A. Weyori, “A systematic review of fundamental and technical analysis of stock market predictions,” Artif. Intell. Rev., vol. 53, no. 4, pp. 3007–3057, Apr. 2020, doi: 10.1007/s10462-019-09754-z.

O. Bustos and A. Pomares-Quimbaya, “Stock market movement forecast: A Systematic review,” Expert Syst. Appl., vol. 156, p. 113464, Oct. 2020, doi: 10.1016/j.eswa.2020.113464.

A. M. Priyatno, W. F. Ramadhan Sudirman, and R. J. Musridho, “Feature selection using non-parametric correlations and important features on recursive feature elimination for stock price prediction,” Int. J. Electr. Comput. Eng., vol. 14, no. 2, p. 1906, Apr. 2024, doi: 10.11591/ijece.v14i2.pp1906-1915.

A. M. Priyatno, W. F. R. Sudirman, R. J. Musridho, and F. Amalia, “Impurity-Based Important Features for feature selection in Recursive Feature Elimination for Stock Price Forecasting,” JUTIN J. Tek. Ind. Terintegrasi, vol. 6, no. 4, pp. 1182–1194, 2023.

A. M. Priyatno, L. S. Tanjung, W. F. R. Sudirman, P. Cholidhazia, P. Z. Jati, and F. I. Firmananda, “Comparison Random Forest Regression and Linear Regression For Forecasting BBCA Stock Price,” J. Tek. Ind. Terintegrasi, vol. 6, no. 3, pp. 718–732, 2023, doi: 10.31004/jutin.v6i3.16933.

S. R. Polamuri, K. Srinivas, and A. Krishna Mohan, “Stock Market Prices Prediction using Random Forest and Extra Tree Regression,” Int. J. Recent Technol. Eng., vol. 8, no. 3, pp. 1224–1228, Sep. 2019, doi: 10.35940/ijrte.C4314.098319.

A. Yelne and D. Theng, “Stock Prediction and analysis Using Supervised Machine Learning Algorithms,” in 2021 International Conference on Computational Intelligence and Computing Applications (ICCICA), Nov. 2021, no. Ml, pp. 1–6. doi: 10.1109/ICCICA52458.2021.9697162.

A. Subasi, F. Amir, K. Bagedo, A. Shams, and A. Sarirete, “Stock Market Prediction Using Machine Learning,” Procedia Comput. Sci., vol. 194, no. 4, pp. 173–179, 2021, doi: 10.1016/j.procs.2021.10.071.

A. H. Khan et al., “A performance comparison of machine learning models for stock market prediction with novel investment strategy,” PLoS One, vol. 18, no. 9 September, pp. 1–19, 2023, doi: 10.1371/journal.pone.0286362.

J. W. Goodell, S. Kumar, W. M. Lim, and D. Pattnaik, “Artificial intelligence and machine learning in finance: Identifying foundations, themes, and research clusters from bibliometric analysis,” J. Behav. Exp. Financ., vol. 32, p. 100577, 2021, doi: 10.1016/j.jbef.2021.100577.

N. Rouf et al., “Stock Market Prediction Using Machine Learning Techniques: A Decade Survey on Methodologies, Recent Developments, and Future Directions,” Electronics, vol. 10, no. 21, p. 2717, Nov. 2021, doi: 10.3390/electronics10212717.

O. Gheibi, D. Weyns, and F. Quin, “Applying Machine Learning in Self-adaptive Systems,” ACM Trans. Auton. Adapt. Syst., vol. 15, no. 3, pp. 1–37, Sep. 2020, doi: 10.1145/3469440.

P. Appiahene, Y. M. Missah, and U. Najim, “Predicting Bank Operational Efficiency Using Machine Learning Algorithm: Comparative Study of Decision Tree, Random Forest, and Neural Networks,” Adv. Fuzzy Syst., vol. 2020, pp. 1–12, Jul. 2020, doi: 10.1155/2020/8581202.

H. Dabiri, V. Farhangi, M. J. Moradi, M. Zadehmohamad, and M. Karakouzian, “Applications of Decision Tree and Random Forest as Tree-Based Machine Learning Techniques for Analyzing the Ultimate Strain of Spliced and Non-Spliced Reinforcement Bars,” Appl. Sci., vol. 12, no. 10, p. 4851, May 2022, doi: 10.3390/app12104851.

N. A. Priyanka and D. Kumar, “Decision tree classifier: a detailed survey,” Int. J. Inf. Decis. Sci., vol. 12, no. 3, p. 246, 2020, doi: 10.1504/IJIDS.2020.108141.

R. Rivera-Lopez, J. Canul-Reich, E. Mezura-Montes, and M. A. Cruz-Chávez, “Induction of decision trees as classification models through metaheuristics,” Swarm Evol. Comput., vol. 69, no. April 2021, p. 101006, Mar. 2022, doi: 10.1016/j.swevo.2021.101006.

M. Ahmad, N. A. Al-Shayea, X.-W. Tang, A. Jamal, H. M. Al-Ahmadi, and F. Ahmad, “Predicting the Pillar Stability of Underground Mines with Random Trees and C4.5 Decision Trees,” Appl. Sci., vol. 10, no. 18, p. 6486, Sep. 2020, doi: 10.3390/app10186486.

M. S. T. T. Del and S. K. Tabrizi, “‘A methodological assessment of the importance of physical values in architectural conservation using Shannon entropy method,’” J. Cult. Herit., vol. 44, pp. 135–151, Jul. 2020, doi: 10.1016/j.culher.2019.12.012.

U. C. Bicici, T. H. S. Meral, and L. Akarun, “Conditional Information Gain Trellis,” arXiv Prepr., vol. cs.cv, no. feb, pp. 1–20, Feb. 2024, doi: 10.48550/arXiv.2402.08345.

A. Kurani, P. Doshi, A. Vakharia, and M. Shah, “A Comprehensive Comparative Study of Artificial Neural Network (ANN) and Support Vector Machines (SVM) on Stock Forecasting,” Ann. Data Sci., vol. 10, no. 1, pp. 183–208, Feb. 2023, doi: 10.1007/s40745-021-00344-x.

J. B. Pandya and P. (Dr. . U. K. Jaliya, “Opinion and Technical Indicator Based Optimized Deep Learning for Prediction of Stock Market,” Indian J. Comput. Sci. Eng., vol. 12, no. 6, pp. 1860–1874, Dec. 2021, doi: 10.21817/indjcse/2021/v12i6/211206166.

D. Singh and B. Singh, “Investigating the impact of data normalization on classification performance,” Appl. Soft Comput., vol. 97, p. 105524, 2020, doi: 10.1016/j.asoc.2019.105524.

S.-X. Lv, L. Peng, H. Hu, and L. Wang, “Effective machine learning model combination based on selective ensemble strategy for time series forecasting,” Inf. Sci. (Ny)., vol. 612, pp. 994–1023, Oct. 2022, doi: 10.1016/j.ins.2022.09.002.

Downloads

Published

13-03-2024

How to Cite

Priyatno, A. M., Ningsih, L., & Noor, M. (2024). Harnessing Machine Learning for Stock Price Prediction with Random Forest and Simple Moving Average Techniques. Journal of Engineering and Science Application, 1(1), 1–8. https://doi.org/10.69693/jesa.v1i1.1

Issue

Section

Articles