DTW vs Pearson correlation: comparing the shape of a move

Updated 2026-10-09 Español·Deutsch·Русский·Italiano·Français·Türkçe·العربية

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.

Pearson · Point by point

Pearson · Point by pointA₁ ↔ B₁; A₂ ↔ B₂; … []AB
  • A₁ ↔ B₁; A₂ ↔ B₂; …
Teaching diagrams with hypothetical numbers. They explain concepts, not the next price move.

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.

DTW · Time alignment

DTW · Time alignmentTime alignment. Distance between curves is not an outcome probability. []AB
  • Time alignment
  • Distance between curves is not an outcome probability.
Teaching diagrams with hypothetical numbers. They explain concepts, not the next price move.

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.

The band is usually set as a fraction of the sample length — on the order of a tenth. On a fifty-candle window that is a few candles of slack in each direction: a move may arrive slightly early or late and still count as the same move, while a delay of a third of the window 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 is usually not discarded but moved to the front as a pre-filter. Anything that cannot reach even crude positional agreement is unlikely to become a good shape match, and spending the expensive comparison 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. A series of changes is markedly noisier than a series of prices, so demanding the same agreement from it makes no sense.

Step matching. No DTW at all. For every pair of adjacent candles you check whether the window's step differs from the sample's by more than a chosen tolerance, and count the fraction of steps that matched. Position-locking returns, but the number becomes explainable in words: "eighty percent of steps agreed to within such-and-such a tolerance."

What the percentages mean

The distance DTW produces is an awkward quantity: on its own it tells a person nothing. So it is folded into a single number running from one hundred downward, and that number is what the slider carries. One hundred percent is a match, and down from there.

The number is computed relative to the sample's own range. Deviation in shape is measured not in absolute percentage points but as a fraction of how far the sample moved up and down at all. The point is simple: 85% on forex, where the window travelled one and a half percent, and 85% on daily crypto, where it travelled forty, mean the same thing — an equally close shape. Until 26 September 2026 the scale was absolute, and patterns with a large range scored low similarity for their size alone.

The key property of this scale is that it is non-linear and especially strict at the top. Moving from 80 to 90 is not "a little stricter" but a markedly harder demand on shape. Hence the practical observation: on a live window a threshold of 90 often returns no matches at all where 80 returns a handful.

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.

See it on a live chart

The same markup on a prepared example: the chart, the objects it found and what followed.

Open the example