Transformer with Technical Indicators for Long-Term Stock Market Prediction
Keywords:
Keywords: Stock Market, Generative Artificial Intelligence, Financial Forecasting, Transformer, Technical IndicatorsAbstract
Accurate long-term stock market prediction is challenging due to the dynamic, non-linear, and volatile nature of financial time series. This study proposes a Transformer-based forecasting model that integrates both short- and long-term technical indicators to improve prediction accuracy on the Kuala Lumpur Stock Exchange (FBM KLCI) index. By leveraging the self-attention mechanism, the model captures both immediate price fluctuations and persistent trends, while positional encoding and stacked encoder blocks enable effective sequential modeling. The proposed approach is compared against several baselines, including an LSTM network, a Transformer using only OHLCV data, and Transformers with either short-term or long-term indicators alone. Evaluation metrics include Mean Absolute Error (MAE), Root Mean Squared Error (RMSE), Mean Absolute Percentage Error (MAPE), as well as training and testing times. Experimental results show that the proposed dual-indicator Transformer consistently outperforms all baselines, achieving the lowest MAE (17.14), RMSE (21.29), and MAPE (1.13%), demonstrating its ability to balance responsiveness to short-term changes with long-term trend stability. While the model requires longer training due to increased complexity, the substantial gains in predictive performance justify the computational cost. These findings highlight the effectiveness of combining multiple technical indicators within a Transformer model for long-term stock market forecasting and provide a foundation for future research incorporating macroeconomic, sentiment, and real-time data to enhance predictive power and generalizability.














