Explainable Deep Learning for Candlestick-Based Analysis Using CNN, Capsule Networks and Grad-CAM++
摘要
The growing use of deep learning in stock market prediction has improved forecasting accuracy, yet its deployment in real trading environments remains limited due to insufficient interpretability and unreliable confidence estimation. This paper presents an explainable deep learning framework for candlestick-based trading signal prediction by combining Convolutional Neural Networks (CNNs), Capsule Networks, and Grad-CAM++ explainability techniques. Historical OHLC data from the NIFTY-50 index are transformed into candlestick chart images using a sliding window strategy and classified into BUY, SELL, and HOLD categories based on future price movements. The CNN component learns spatial and texture-level representations of price action, while Grad-CAM++ generates high-resolution visual explanations that identify the most influential candlestick regions contributing to each decision. To capture structural market relationships and provide meaningful confidence measures, a Capsule Network is employed, where the magnitude of class-specific capsule vectors reflects the strength of detected trading patterns. Experimental evaluation demonstrates that the CNN and Capsule Network achieve accuracies of 84.78% and 83.69%, respectively, with F1-scores above 78%. The proposed framework delivers dual-level explainability and enhances trust, transparency, and usability of deep learning models for real-world financial decision-making and regulatory-compliant trading systems.