Home › Documentation › Edge discovery
Finder

AQ Pattern Miner historical analogy

It opens from Strategies → AQ Pattern Miner. It is the only module in AniQuant that uses neither indicators nor rules: it takes the shape of the last few candles, searches the whole history for the moments that most resemble it, and looks at what happened next. The past does not repeat itself, but it rhymes.

How it works

It compares shape, not price. Before measuring anything, every window is normalized —its mean is subtracted and it is divided by its standard deviation— so a stretch of @ES at 4,000 points and another at 2,000 can resemble each other perfectly. What is compared is the drawing, not the level or the scale.

Candles K = 20

How many candles make up the figure you are looking for. More candles = stricter and scarcer analogies.

Horizon H = 10

How many candles forward are examined in each analog to see «what happened next».

Neighbors M = 30

How many analogs are kept — the most similar ones in the whole series.

It works with the close only. It discards the windows that overlap the one you are asking about —otherwise the best analog would always be itself— and the completely flat ones. And it requires at least H candles to exist after the analog: a resemblance that ends with the series is of no use.

What you see

The center of the window is the rhyme chart: your current shape in a thick line, the M analogs overlaid faintly, and to the right of the divider —the «now»— how each one continued, forming a green or red cone. In gold, the average future of all of them.

The figures

How many analogs rose, the mean and median return, and the dispersion — which is what tells you whether they agree or each went its own way. Below, the average return candle by candle, from 1 to H.

The table of analogs

Each analog with its rank number —number 1 is the most similar—, its date, its distance and its future return. It sorts by any column, you walk it with the arrow keys and the chosen row is marked in amber. Double-click or Enter and the module analyzes that moment — you can hop from rhyme to rhyme back through history.

The slider, with its two markers

You are not obliged to ask about today. The solid marker is the date being analyzed: move it and you are asking about any point in history, which is how you check whether the module would have told you anything useful at a moment whose outcome you already know. The ◀ ▶ buttons move exactly one candle, because dragging is not that precise.

The hollow marker shows where the analogs are searched for. All the way left, the stretch is «from the start of the file». Drop it two or three years before the analysis date and both the analogs and the bar come only from that period — which is another market. The two markers push each other, but they never cross.

All three charts have a magnifier: hovering over them makes it appear in the corner and a click opens them full screen (Esc to close). With the magnifier open the big chart follows the slider, so you can walk the history watching the rhyme large. The panels below are resized by dragging their dividers, and the size is remembered.

The slider no longer peeks at the future

A very easy mistake lurks here, and precisely in the module whose whole job is not to fool itself. With the slider on today there is no danger —there is no future to look at—, but dragging it to a past date, a naive search would sweep the entire file and answer «what happened after figures like this one» with cases that had not happened yet. To give you the size of the bias: in the middle of the @ES history, 16 out of every 30 analogs would come from the future.

The «Past only» checkbox is now on by default and requires the analog and its outcome to fit entirely before the chosen date. The window states in green how many windows it discarded for falling in the future. Unchecking it goes back to looking at everything, which is useful for exploring where a shape has rhymed throughout history — never for drawing an expectation; and then it warns you in amber, because the dangerous case is the silent one.

Settling for «the analog ends before the query» would not have been enough: its H outcome candles could still fall afterwards, which is the same trap in disguise.

The bar: what the verdict is compared against

«After these figures it rose 58% of the time» sounds good… until you find out that that market rises 59% of the time all by itself. Then the signal is not merely weak: it is worse than doing nothing. A figure with no reference is not a measurement.

The module now computes that bar —how many of all the candidate windows rose over H candles— and publishes the Edge: the difference, in points. That is the figure to read. It goes green from +5 points up, red below −5, and it has its own sentence in the verdict.

@ES · H = 1 candle
53.5%
@ES · H = 10 candles
59.5%
@ES · H = 250 candles
75.7%

That is why the bar cannot be a fixed number: it moves twenty-two points with the horizon on @ES, and on @CL it stays flat at 53% whatever you do. It depends on H, on the symbol, on the timeframe and on the stretch you choose with the two markers. It is recomputed in full on every query, over the same candles the analogs are searched in, so it cannot fall out of step with them.

The «Calibration» tab: the arithmetic, in plain sight

The bar does not have to be taken on faith: it can be checked. The right-hand panel has two tabs — Analogs, the usual table, and Calibration— with the whole division: the formula, the stretch in indices and in dates, how many windows were counted, how many rose and the result. With daily @ES, K=20 and H=10 over the whole history: 3,985 / 6,701 = 59.47%.

Below, the same calculation horizon by horizon, from 1 to H, with the bar, the analogy and the edge at each one — and drawn in the left-hand panel, where the gap between the two lines is the edge. There you see whether the edge was in the first candle and then died out, or the other way round.

The Edge is directional. If the analogy says it falls 75% of the time and the market rises 59% on its own, the fall rate goes from 41% to 75%: that is +34 points in your favor, not −34. Always subtracting «upward» painted the best short signals red.

📏 The bar and the measurement, on the same bars

The Edge is a subtraction —hits minus drift— and its two terms are computed over exactly the same bars. It matters more than it seems: if one of the two let negative prices through, a stretch rising from −10 to −5 would be recorded as a 50% fall — the sign, exactly backwards.

It only affects back-adjusted series with prices ≤ 0; on @ES, @NQ or @GC it changes nothing. But where it does bite, the number you read can move by a factor of twenty. Measured on a crude oil continuous, discarding those bars changes the figures like this:

Neighbors
4,947 → 4,774
Edge
−0.76 → −0.03
Dispersion
1.65 → 1.24

Confidence: agreement × resemblance

Confidence answers not one question but two. The first is how many analogs point the same way. The second, the one that gets forgotten, is do they actually look alike? — because if there is nothing in the whole history like today, twenty windows agreeing are worth nothing.

That is why, next to the confidence, you will see «Analog resemblance», as a percentage, with a sentence underneath saying what it means, which turns amber when it drops below 80%. Confidence is the product of the two things: a lot of agreement among analogs that do not look like today gives a low figure, and rightly so.

Resemblance 96% · agreement 40
Confidence 40
untouched
Resemblance 70% · agreement 33
Confidence 6
it deflates

The good analogies are left alone; the weak ones deflate, which is what they should always have done. A note on where the line sits: searching among thousands of bars, something reasonably similar always turns up — measured on @ES, @GC and SPY, the resemblance falls between 74% and 97% —, so a theoretical bar «from 0 to 100» would never have acted. This one spreads out within the real range.

What it is NOT

It is not a strategy, nor a backtest. The Pattern Miner answers for one specific moment: what has historically happened after figures like this one. It does not walk the series taking decisions, nor does it produce a results curve, and its confidence is not a probability of success — it is a measure of how much it trusts its own analogs. Use it to form a hypothesis; to find out whether that hypothesis makes money, there is the rest of the program.

Try it yourself

AniQuant can be tried free for 30 days, with every module and no card.

← Previous
Atomic Edge Scanner
Next →
AQ Mentor: reverse engineering
More in Edge discovery