Enhancing Technical Analysis with Machine Learning: Insights from Emerging Markets with Application to the Tehran Stock Exchange

Document Type : Research Paper

Authors

Department of Economics, university of Urmia, Urmia, Iran.

Abstract

Predicting stock price movements in emerging markets like Iran is especially daunting due to acute volatility, data scarcity, and structural fragility. We propose a statistically rigorous, context-aware framework that fuses technical analysis with machine learning — including XGBoost, Random Forest, Artificial Neural Networks (ANNs), and Linear Model (LM) — aimed at predicting daily stock returns across multiple industry segments of the Tehran Stock Exchange. Using daily observations from six industrial sectors (Automotive, Financial, Food, Pharmaceutical, Basic Metals, Petroleum) between March 24, 2020 and August 21, 2024, we show that no single model reigns supreme across all domains. In the Financial and Basic Metals sectors, XGBoost delivers statistically superior predictive accuracy (Diebold–Mariano test, p < 0.05). In the highly volatile Petroleum sector, ANN distinctly captures extreme nonlinear dynamics, outperforming alternatives. Surprisingly, in more stable sectors like Pharmaceutical and Food, the Linear Model — with its structural simplicity — surpasses more sophisticated algorithms. Random Forest meanwhile operates as a dependable, interpretable benchmark, consistently delivering solid performance across varied conditions. These results challenge the “more complexity is always better” assumption and underscore that optimal modeling must be sector-specific, backed by rigorous statistical validation, and assessed via risk-adjusted forecasting metrics. Our framework offers a replicable, adaptive blueprint for return-based algorithmic forecasting in data-constrained, high-volatility settings — setting a new methodological standard for emerging markets globally.

Keywords

Main Subjects


Article Title [Persian]

بهبود تحلیل تکنیکال با یادگیری ماشین: بینش‌هایی از بازارهای نوظهور با کاربرد در بورس اوراق بهادار تهران

Authors [Persian]

  • فاطمه انصاری
  • شهاب جهانگیری
  • علی رضازاده
دانشکده اقتصاد و مدیریت، دانشگاه ارومیه، ارومیه، ایران.
Abstract [Persian]

پیش‌بینی حرکات قیمت سهام در بازارهای نوظهور مانند ایران به‌دلیل نوسان شدید، کمبود داده‌ها و شکنندگی ساختاری بسیار دلهره‌آور است. ما چارچوبی آماری دقیق ارائه می‌دهیم که تحلیل تکنیکال را با یادگیری ماشین شامل XGBoost، جنگل تصادفی، شبکه عصبی مصنوعی (ANN) و مدل خطی (LM) ترکیب می‌کند تا بازدهی روزانه سهام را در بخش‌های صنعتی مختلف بورس تهران پیش‌بینی کند. با استفاده از داده‌های روزانه شش بخش (خودرو، مالی، غذا، دارویی، فلزات پایه و نفت) طی دوره ۲۴ مارس ۲۰۲۰ تا ۲۱ اوت ۲۰۲۴، نشان می‌دهیم که هیچ مدلی در تمام بخش‌ها برتر نیست. XGBoost در بخش‌های مالی و فلزات پایه عملکرد آماری برتری دارد (آزمون دیبولد–ماریانو، p<0.05). در بخش نفت با نوسان بالا، ANN به‌دلیل مدل‌سازی روابط غیرخطی پیچیده، عملکرد بهتری دارد. در مقابل، در بخش‌های پایدارتر مانند دارویی و غذا، مدل خطی با سادگی ساختاری‌اش از الگوریتم‌های پیچیده‌تر پیشی می‌گیرد. جنگل تصادفی نیز به‌عنوان معیاری قابل اعتماد و قابل تفسیر، عملکرد پایداری از خود نشان می‌دهد. این یافته‌ها فرض «پیچیدگی بیشتر همیشه بهتر است» را به چالش می‌کشد و تأکید می‌کند که مدل‌سازی بهینه باید مختص هر بخش باشد، با اعتبارسنجی آماری دقیق پشتیبانی شود و از طریق معیارهای پیش‌بینی تعدیل‌شده با ریسک ارزیابی شود. چارچوب ما الگویی تطبیق‌پذیر و قابل تکرار برای پیش‌بینی الگوریتمی در محیط‌های پرنوسان و کم‌داده ارائه می‌دهد و استاندارد روش‌شناختی جدیدی برای بازارهای نوظهور جهانی تعیین می‌کند.

Keywords [Persian]

  • یادگیری ماشین
  • تحلیل تکنیکال
  • بازارهای نوظهور
  • پیش‌بینی حرکات قیمت سهام
  • آزمون دیبولد-ماریانو
Afshari Rad, Elham, Alavi, Seyyed Anait Elah, and Sinaii, Hassan Ali. (2017). An intelligent model for predicting stock trends using technical analysis methods. Financial Research, 20(2), 249-264 ).
Ajiga, D. I., Adeleye, R. A., Tubokirifuruar, T. S., Bello, B. G., Ndubuisi, N. L., Asuzu, O. F., & Owolabi, O. R. (2024). Machine learning for stock market forecasting: a review of models and accuracy. Finance & Accounting Research Journal, 6(2), 112-124.
Ali, M., Khan, D. M., Alshanbari, H. M., & El-Bagoury, A. A. A. H. (2023). Prediction of complex stock market data using an improved hybrid emd-lstm model. Applied Sciences, 13(3), 1429.‏
Amini Mehr, Amin, Raofi, Ali, Amini Mehr, Akbar and Amini Mehr, Amir Hossein. (2019). The effect of different data preprocessing methods for predicting Tehran Stock Exchange index using short-term and long-term persistent memory neural network. (Iranian Journal of Economic Studies (IJES, 9(2), 527-548. doi: 10.22099/ijes.2021.39877.1739
Ayala, J., García-Torres, M., Noguera, J. L. V., Gómez-Vela, F., & Divina, F. (2021). Technical analysis strategy optimization using a machine learning approach in stock market indices. Knowledge-Based Systems, 225, 107119.
Baker, H. K., & Ricciardi, V. (2014). How biases affect investor behaviour. The European Financial Review, 7-10.‏
Bao, T.; Nekrasova, E.; Neugebauer, T.; Riyanto, Y.E. Algorithmic Trading in Experimental Markets with Human Traders: A Literature Survey. In Handbook of Experimental Finance; Sascha, F., Ernan, H., Eds.; Edward Elgar Publishing: Cheltenham, UK, 2021.
Box, G. E. P., Jenkins, G. M., & Reinsel, G. C. (2008). Time Series Analysis: Forecasting and Control. Wiley.
Breiman, L. (2001). Random forests. Machine Learning, 45(1), 5-32.
Cervelló-Royo, R., & Guijarro, F. (2020). Forecasting stock market trend: A comparison of machine learning algorithms. Finance, Markets and Valuation, 6(1), 37-49.
Chen, T., & Guestrin, C. (2016). XGBoost: A scalable tree boosting system. In Proceedings of the 22nd ACM SIGKDD International Conference on Knowledge Discovery and Data Mining (pp. 785–794). https://doi.org/10.1145/2939672.2939785
Damodaran, A. (2021). The Little Book of Valuation: How to Value a Company, Pick a Stock, and Profit. Wiley.
Efendi, R., Arbaiy, N., & Deris, M. M. (2018). A new procedure in stock market forecasting based on fuzzy random auto-regression time series model. Information Sciences, 441, 113-132.‏
Fama, E. F. (1970). Efficient capital markets: A review of theory and empirical work. Journal of Finance, 25(2), 383-417.
Geweke, J., Horowitz, J. L., & Pesaran, H. (2008). The New Palgrave Dictionary of Economics Online.‏
Gholamian, Elham; Davoudi, Mohammadreza (2017). Forecasting the price trend in the stock market using random forest algorithm. Journal of Financial Engineering and Securities Management, (9) 35, 322-301).
González-Núñez, E., Trejo, L. A., & Kampouridis, M. (2024). A Comparative Study for Stock Market Forecast Based on a New Machine Learning Model. Big Data and Cognitive Computing, 8(4), 34.‏
Graham, B., & Dodd, D. (1934). Security Analysis. McGraw-Hill Education.
Guresen, E., Kayakutlu, G., & Daim, T. U. (2011). "Using artificial neural network models in stock market index prediction." Expert Systems with Applications, 38(8), 10389-10397.
Haykin, Neural Networks: A Comprehensive Foundation, Prentice Hall, 1994.
Heaton, J. B., Polson, N. G., & Witte, J. H. (2017). Deep learning for finance: deep portfolios. Applied Stochastic Models in Business and Industry, 33(1), 3-12.
Hossain, E., Hossain, M. S., Zander, P. O., & Andersson, K. (2022). Machine learning with Belief Rule-Based Expert Systems to predict stock price movements. Expert Systems with Applications, 206, 117706.
Koller, T., Goedhart, M., & Wessels, D. (2020). Valuation: Measuring and Managing the Value of Companies (7th Edition). Wiley.
Lo, A. W., & Hasanhodzic, J. (2020). The Evolution of Technical Analysis: Financial Prediction from Babylonian Tablets to Bloomberg Terminals. Wiley.
Mak, D. K. (2021). Moving Average Convergence-Divergence and Its Histogram. Trading Tactics in the Financial Market: Mathematical Methods to Improve Performance, 85-95.‏
Masry, M. (2017). The Impact of Technical Analysis on Stock Returns in an Emerging Capital Markets (ECM’s)) Country: Theoretical and Empirical Study. International Journal of Economics and Finance, 9(3), 91-107.
Mulloy, P. G. (1994). Smoothing data with faster moving averages. Stocks & Commodities, 12(1), 11-19.‏
Murphy, J. J. (2021). Technical Analysis of the Financial Markets: A Comprehensive Guide to Trading Methods and Applications. New York: Penguin Publishing Group.
Nabipour, M., Nayyeri, P., Jabani, H., Mosavi, A., & Salwana, E. (2020). Deep learning for stock market prediction. Entropy, 22(8), 840.‏
Najem, R., Bahnasse, A., & Talea, M. (2024). Toward an Enhanced Stock Market Forecasting with Machine Learning and Deep Learning Models. Procedia Computer Science, 241, 97-103.‏
Reddy, V. K. S., & Sai, K. (2018). Stock market prediction using machine learning. International Research Journal of Engineering and Technology (IRJET), 5(10), 1033-1035.‏
Saberironaghi, M., Ren, J., & Saberironaghi, A. (2025). Stock Market Prediction Using Machine Learning and Deep Learning Techniques: A Review. AppliedMath, 5(3), 76.‏
Sangeetha, J. M., & Alfia, K. J. (2024). Financial stock market forecast using evaluated linear regression based machine learning technique. Measurement: Sensors, 31, 100-950.‏
Sayadi, Mohammad and Omidi, Meysam. (2019). Forecast-Based Portfolio Optimization for Oil-Related Group Stocks in Iran Using Data Mining Methods. (Iranian Journal of Economic Studies (IJES, 8(2), 225-252. doi: 10.22099/ijes.2020.34367.1595
Schwager, J. D. (2020). Technical Analysis for Dummies (4th Edition). Wiley.
Shah, D., Isah, H., & Zulkernine, F. (2019). "Stock market analysis: A review and taxonomy of prediction techniques." International Journal of Financial Studies, 7(2), 26.
Sharpe, W. F. (1964). Capital asset prices: A theory of market equilibrium under conditions of risk. Journal of Finance, 19(3), 425-442.
Sharpe, W. F. (1966). Mutual fund performance. The Journal of business, 39(1), 119-138.‏
Skabar, A., & Cloete, I. (2002). Neural networks, financial trading and the efficient markets hypothesis. In ACSC: 241-249.
Wang, B., Guo, Y., Zhang, Z., Wang, D., Wang, J., & Zhang, Y. (2023). Developing and applying OEGOA-VMD algorithm for feature extraction for early fault detection in cryogenic rolling bearing. Measurement, 216, 112908.‏
Wang, J., & Wang, J. (2015). Forecasting stock market indexes using principle component analysis and stochastic time effective neural networks. Neurocomputing, 156, 68-78.‏
Wang, F., & Wang, J. (2012). Statistical analysis and forecasting of return interval for SSE and model by lattice percolation system and neural network. Computers & Industrial Engineering, 62(1), 198-205.‏
Wu, Y. (2014). Network Big Data: A Literature Survey on Stream Data Mining. J. Softw., 9(9), 2427-2434.‏
Yu, G., & Wenjuan, G. (2010). Decision tree method in financial analysis of listed logistics companies. International conference on intelligent computation technology and automation.