Abstract
PRML, a novel candlestick pattern recognition model using machine learning methods, is proposed to improve stock trading decisions. Four popular machine learning methods and 11 different features types are applied to all possible combinations of daily patterns to start the pattern recognition schedule. Different time windows from one to ten days are used to detect the prediction effect at different periods. An investment strategy is constructed according to the identified candlestick patterns and suitable time window. We deploy PRML for the forecast of all Chinese market stocks from Jan 1, 2000 until Oct 30, 2020. Empirical results show that the two-day candlestick patterns after filtering have the best prediction effect when forecasting one day ahead; these patterns obtain an average annual return, an annual Sharpe ratio, and an information ratio as high as 36.73%, 0.81, and 2.37, respectively.
Introduction
Predicting stock market movements is a complex challenge characterized by high noise and market efficiency. While "candlestick charting" has been a staple of technical analysis for centuries, its effectiveness is often dismissed in academic circles as subjective or inconsistent. Traditional research typically focuses on a small subset of well-known patterns, such as the "Hammer" or "Doji," failing to account for the vast number of possible multi-day combinations.
This paper introduces the PRML (Pattern Recognition Machine Learning) model, a framework designed to transform candlestick analysis into a rigorous, data-driven discipline. By leveraging machine learning to discover specific sequences of price action with predictive power, the study aims to identify profitable trading opportunities across thousands of stocks.
Methodology
The PRML model utilizes a "bottom-up" construction approach to identify and validate profitable patterns. The workflow integrates stock data and technical indicators into machine learning models for evaluation and recommendation.
Pattern Building and Feature Engineering
The researchers defined 13 basic one-day candlestick forms. These forms serve as the building blocks for 169 possible two-day patterns and 2,197 possible three-day patterns. For every pattern, 11 feature types were calculated, including "Shape" (geometry), "Loc" (relative price position), and nine technical indicators such as Moving Averages (MA) and On-Balance Volume (OBV).
Algorithmic Selection and Validation
Four primary machine learning models were tested: Logistic Regression (LR), K-Nearest Neighbors (KNN), Random Forest (RF), and Restricted Boltzmann Machines (RBM). To ensure robustness, findings were cross-validated using Deep Learning models, specifically Multilayer Perceptron (MLP) and Long Short-Term Memory (LSTM) networks. The study utilized a massive dataset from the Chinese stock market (CCER) spanning from 2000 to 2020, with 2000–2014 used for training and 2015–2020 for out-of-sample verification.
Results and Discussion
The empirical results demonstrate significant outperformance compared to the Shanghai Composite Index (SH Index), which returned -0.66% annually during the test period.
- The "Sweet Spot" of Complexity: Two-day patterns were found to be the most effective. While three-day patterns provide more context, their lower frequency in the data makes models more prone to overfitting.
- Short-Term Dominance: Predictive power decays rapidly; forecasting one day ahead yielded the best results, suggesting patterns capture immediate supply-demand imbalances.
- Profitability: The TOP10 two-day pattern strategy achieved a 36.73% average annual return. Even after accounting for a 0.2% transaction cost, the strategy remained highly profitable with a 24.45% annual return.
- Risk Management: The model maintained an Information Ratio of 2.37 and a Sharpe Ratio of 0.81. Furthermore, the PRML-based portfolios showed significantly lower maximum drawdowns (16.43% for TOP10) compared to the broader market (52.28%).
Conclusion
The PRML framework successfully identifies profitable candlestick patterns by combining traditional technical analysis with modern machine learning. While the study highlights the effectiveness of two-day patterns in the Chinese market, limitations remain regarding sample sizes for complex patterns and market-specific volatility. Future research may incorporate alternative data, such as news sentiment, and further optimize deep learning architectures to enhance predictive accuracy.
Summary updated