Candlestick charts are a cornerstone of technical analysis. While many traders rely on a handful of classic formationssuch as hammer, shooting star, or engulfingthose patterns were historically identified by human intuition. Recent advances in machine learning enable a datadriven, unsupervised approach that can surface new, statistically significant patterns without any prior labeling. This page explains the rationale, methodology, and practical considerations for uncovering such patterns. Traditional pattern research follows a topdown path: a trader proposes a shape, then tests its predictive power. This approach suffers from two biases: Unsupervised learning sidesteps these pitfalls by letting the data speak. Instead of specifying a particular shape, algorithms cluster similar priceaction sequences, then rank clusters by statistical relevance (e.g., Sharpe ratio, winrate, or information ratio). The result is a set of emergent patterns that may be simple or intricate, each backed by a quantitative performance metric. Patterns can be searched across any resolutiontick, minute, hourly, daily. Higherfrequency data provides richer detail but increases computational load and noise. A common practice is to start with daily bars for equities or 5minute bars for futures, then refine the analysis at a finer granularity if a pattern proves robust. Raw OHLC values differ dramatically between instruments. To compare shapes, each candlestick is transformed into a scaleinvariant representation: These three ratios sum to 1, providing a compact vector that preserves the essential geometry while discarding absolute price levels. To discover multicandle patterns, the price series is divided into overlapping windows. Typical lengths range from 2 to 6 candles; the window slides one bar at a time, generating a large collection of candidate sequences. Once the windows are encoded, a clustering algorithm groups similar sequences. The choice of method influences both speed and the type of patterns uncovered. Kmeans is fast and intuitive. By setting HAC builds a dendrogram by merging the two closest clusters iteratively. By cutting the tree at a particular distance threshold, you can obtain a variable number of clusters that respect the natural similarity scale in the data. DBSCAN identifies dense regions of the feature space and treats outliers as noise. This is useful for discovering rare yet highly significant patterns that would be hidden in large clusters formed by more common shapes. Deep autoencoders can compress the candlestick window into a lowdimensional latent space. Clustering is then performed on these latent vectors, allowing the discovery of nonlinear relationships that traditional distance metrics may miss. Clustering produces many candidate patterns, but only a subset will be truly useful. The following quantitative tests help filter out spurious formations. For each cluster, compute the average forward return over a chosen horizon (e.g., 5 days). Metrics to examine include: Apply a ttest or bootstrap analysis to assess whether the observed performance differs from zero with high confidence. A pvalue below 0.01 is a common threshold for considering a pattern significant. Validate the pattern on outofsample data, across different market regimes, and on unrelated assets. Consistency across these tests reduces the likelihood that the pattern is a statistical artefact. After filtering, the remaining clusters can be examined visually. A useful practice is to plot the centroid of each cluster as a schematic candlestick diagram, alongside a few real examples that belong to the cluster. This helps traders understand the intuition behind the machinediscovered shape. Example Insight: One discovered 3candle pattern consisted of a small bullish candle followed by a long bearish candle that closed near its low, and finally a doji that opened and closed at the same level as the second candles low. The forward test showed a 1.8% average return over the next three days, with a Sharpe of 1.3significantly better than random chance. The pattern can be thought of as a threestep reversal that is not captured by standard textbook patterns. Remember that the utility of any pattern depends on the trading style. Highfrequency traders may value very shortterm edges, while swing traders might prefer patterns that manifest over several days. Unsupervised discovery is a rapidly evolving field. Several promising extensions include: As computational resources become cheaper and data availability increases, the blend of unsupervised learning with classic technical analysis is expected to broaden the toolbox of quantitative traders.Unsupervised Discovery of Significant Candlestick Patterns
Why Unsupervised Discovery?
Data Preparation
1. Choosing the Timeframe
2. Normalising Candlesticks
body = (close - open) / (high - low) captures the proportion of the body relative to the full range.wick_up = (high - max(open, close)) / (high - low)wick_down = (min(open, close) - low) / (high - low)3. SlidingWindow Segmentation
Clustering Techniques
KMeans & Variants
k (the number of clusters) and running several initialisations, the algorithm converges to centroids that represent average shapes. The downside is the assumption of spherical clusters and the need to guess k ahead of time.Hierarchical Agglomerative Clustering (HAC)
DBSCAN (DensityBased Spatial Clustering)
AutoEncoder Feature Extraction
Evaluating Pattern Significance
ForwardLooking Performance
Statistical Significance
Robustness Checks
Interpreting the Results
Practical Implementation Tips
Future Directions
Key Takeaways
