How we find similar situations in chart history

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

Most tools that claim to "find patterns" never say what they compare, how closely, or what they throw away. This page walks through the decisions such a search requires, and what each of them costs you.

The job: take the most recent stretch of a chart and find every place in that instrument's history where price moved in a similar way. Then look at what happened after each one.

The sample window

You compare a stretch against a stretch. The stretch you are searching for is the sample, and its length is the first decision.

We offer 20, 50, 60 and 100 candles; the default is 50. Both ends of that range fail in predictable ways. At 20 candles the shape carries too little information — almost any 20-bar move has happened before, so matches are plentiful and meaningless. At 100 the shape is so specific that exact analogues may not exist at all.

Length also silently sets the timescale. Fifty four-hour candles is roughly eight days. Fifty daily candles is two and a half months. The same slider means very different things on different timeframes.

Sample

Sample [105, 100, 103, 98, 109]98109Time →

Historical analogue

Historical analogueOne shape at different scales [210, 200, 206, 196, 218]196218Time →
  • One shape at different scales
Teaching diagrams with hypothetical numbers. They explain concepts, not the next price move.

Slicing the history

The instrument's history is then cut into every possible window of that length: candles 1–50, 2–51, and so on. On a long history that adds up to tens of thousands of windows.

Each one is a candidate. The problem reduces to scoring all of them and keeping those above a threshold.

Normalisation: shape, not price

Compare raw prices and Bitcoin at 20,000 will never resemble Bitcoin at 90,000, however identical the movement. Absolute levels carry no information about shape.

So every window is converted to percentage change from its own first candle. A window that ran 20,000 → 21,000 and a window that ran 90,000 → 94,500 look identical afterwards: plus five percent from the start. We compare the trajectory, not the price tag.

That choice has a cost, and we pay it two steps down.

The cheap pre-filter

Twenty thousand candidates is a lot if each one goes through an expensive algorithm. So the first pass is deliberately cheap: a Pearson correlation between the sample and the window, computed vectorised in batches of two thousand.

The cut-off here is deliberately crude, and different for different quantities: a series of changes is markedly noisier than a series of prices, and demanding the same agreement from it makes no sense.

Pearson is crude. It compares points strictly by position and does not forgive a shift in time. As a first pass that is exactly what you want: anything failing even crude agreement will not survive the shape comparison either. Only a minority of candidates reaches the expensive stage. Why the crude measure cannot replace the precise one is covered in the DTW comparison.

Dependent observations

Dependent observationsOverlap: A ∩ B ∩ C. Repeating one episode does not enlarge an independent sample. []ABCTime →
  • Overlap: A ∩ B ∩ C
  • Repeating one episode does not enlarge an independent sample.
Teaching diagrams with hypothetical numbers. They explain concepts, not the next price move.

The amplitude gate

Here the cost of normalisation comes due. The main algorithm is scale-invariant: a one-percent drift and a twenty-three-percent collapse with the same outline score as similar, because after normalisation they genuinely are similar in shape.

That is useless in practice. A quiet drift and a crash are different events, and studying the aftermath of one to understand the other is a mistake.

So a separate check on total movement is added to the shape comparison: the window's net change must not differ too much from the sample's. There is a subtlety — if the sample's net change is near zero, a relative tolerance collapses to nothing and admits nobody, so some absolute floor is needed as well.

The similarity threshold

Similarity is expressed as a percentage: 100 is identical, downward from there.

The steps on such a scale are not equivalent, and that is worth understanding before you touch the slider. The top of the scale is very strict: demanding a near-exact shape match frequently returns nothing at all on a live window. Closer to the middle the picture changes abruptly — matches appear, but "similar" has become generous by then.

It is worth checking this yourself on your own instrument: walk the thresholds from the top down and see where the output stops being empty and where it starts filling with junk. The break points differ between instruments, and there is no universal "correct threshold".

The practical consequence is worth stating bluntly: the lower the threshold, the easier it is to find support for whatever you already believe. Drop the slider until the picture looks convincing and you have learned something about your filtering, not about the market.

Non-overlapping matches

Adjacent windows differ by one candle and resemble each other almost as much as they resemble the sample. Keep them all and a dozen genuinely distinct episodes become a hundred rows, with any statistic counting the same event over and over.

So each cluster of overlapping windows contributes one entry, the best of them. The matches then represent different places in history, not shifts of the same window.

What you actually get

A handful of decisions in sequence: window length, shape normalisation, a cheap first pass, a check on total movement, and the similarity threshold. Each can be made differently, and each changes the answer.

The output is a list of places where price moved in a comparable way, plus a picture of what followed each. That is a description of the past. Computing the share of outcomes does not convert it into a forecast — what the statistics do and do not support is a separate discussion.

Short answers on this topic

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