We run both. Not as a hedge — they do different jobs, and neither can do the other's.
This page explains where each one breaks, which is the part that usually gets skipped.
Pearson compares points by position
Pearson correlation takes two sequences of equal length and measures how consistently they deviate from their own means. Point one against point one, point ten against point ten, point fifty against point fifty.
That is fast and, for many problems, enough. But the rigid position mapping has a weakness that charts trigger constantly.
Two episodes: in both, price fell, paused, and turned up. The first fall took eight candles, the second twelve. A human calls that the same figure, stretched. Pearson calls it weakly correlated — by the time the first sequence is turning, the second is still falling, and the positions disagree.
Markets are under no obligation to repeat a move at the same speed. Position-locked comparison discards matches that are matches.
What DTW does
Dynamic Time Warping addresses exactly that. Instead of forcing point i onto point i, it searches for the best alignment while allowing time to stretch: one point of the sample may correspond to several points of the window and vice versa.
A distance matrix is built between all pairs of points, and the minimum-cost path from start to end is found. Diagonal steps mean point-for-point agreement; sideways steps mean one sequence was moving slower here.
The result is the accumulated distance along that path. Smaller is more similar.
Why unconstrained DTW is worthless
Freedom to stretch time cuts both ways. Allow arbitrary warping and the algorithm will find a decent alignment between almost any two sequences — it simply maps the first half of one onto a single point of the other and spreads the rest.
Such a match means nothing. A figure stretched tenfold is not the same figure.
So DTW is constrained to a band around the diagonal: point i may only align with points near index i. This is the Sakoe-Chiba band, and its width is the parameter that matters.
Ours is ten percent of the sample length. On a fifty-candle window that is five candles of slack in each direction: a move may arrive five bars early or late and still count as the same move. Fifteen bars late does not.
Ten percent is a choice, not a constant handed down from anywhere. Wider means more matches and more noise; narrower degenerates back into position-locked comparison.
So why keep Pearson
DTW costs orders of magnitude more than a single pass: a matrix has to be filled instead of a vector scanned. Across twenty thousand windows that is the difference between instant and noticeable.
So Pearson was not dropped, it was moved to the front as a pre-filter — 0.70 for price-based methods, 0.50 for change-based ones. Anything that cannot reach even that crude level of agreement will not become a good shape match, and spending DTW on it is waste.
The division of labour is clean: Pearson cheaply removes the obviously unrelated, DTW carefully scores what is left.
Three ways to compare
Three methods, differing in what is fed to the algorithm.
By price. The sequence of normalised prices — percent from the window's first candle. The trajectory itself is compared. This is the default.
By change. The sequence of candle-to-candle moves. Trajectory is ignored; what matters is the rhythm — where the sharp steps were and where the quiet ones. The Pearson gate is looser here, 0.50, because a series of changes is markedly noisier.
Step matching. No DTW at all. First the window's total move must be close to the sample's. Then, for every pair of adjacent candles, the window's step must differ from the sample's by no more than 0.75 percentage points. Similarity is simply the fraction of steps that matched. Position-locking returns, but the number becomes explainable in words: "eighty percent of steps agreed to within three quarters of a point."
From distance to a percentage
For the DTW methods, similarity is one hundred divided by one plus the distance. Distance zero gives 100, distance one gives 50, and the curve falls away quickly after that.
The scale is therefore non-linear and very strict at the top. Reaching ninety percent requires a distance around one ninth — a near-exact match. The gap between thresholds 90 and 80 is far wider than the gap between 80 and 70, even though the slider step is identical.
Step matching uses a different scale entirely: similarity there is the matched fraction times one hundred, so eighty percent means four steps in five. The same number on the slider means different things depending on the method — worth remembering when you switch.
What this means in practice
Choosing the algorithm is not a technical detail. It is a decision about which episodes you consider similar.
If the exact trajectory matters, use the price method. If the character of the movement matters more than its direction, use the change method. If you want every percentage point to be explainable, use step matching.
In all three cases the output is the same kind of thing: places in history with a comparable outline. What happened afterwards is a separate question, and one that deserves care.