Chart-Pattern Analogs SMC-Graded Chart-Pattern Analogs — Empirical Matching, SMC-Graded & Calibrated
## What it is
A chart-pattern engine that does not trust textbook shapes — it predicts from **precedent**. Instead of asking "does this look like a Head & Shoulders?", it asks "**how did the closest historical shapes on this symbol actually resolve?**" and answers from data.
A PIP (Perceptually Important Points) skeleton of the recent window is matched by **Dynamic Time Warping** against a live memory of past shapes, each labelled by what happened next. The direction, probability and target come from the *k* nearest analogs. Each completed pattern is then graded with Smart-Money context (liquidity sweeps, premium/discount location, breakout quality), and its forward outcome is tracked **per family, per regime, with Wilson confidence intervals**. Templates and geometry survive only to *name* the family.
## Why these components belong in ONE script (not a stack of indicators)
This matters because the components form **one closed loop**, where each answers a question the others cannot:
- **PIP skeleton + Ehlers-adaptive window** reduce price to its structurally important turning points, over a window sized by the live dominant cycle so the skeleton tracks the market's actual rhythm rather than a fixed bar count.
- **DTW analog matching** replaces fixed templates: the current skeleton is compared to a memory of *resolved* shapes, and the forward outcome of its nearest neighbours **is** the prediction. Empirical, not assumed.
- **SMC context** (liquidity sweeps, EQH/EQL pools, premium/discount, breakout quality) answers *"is this the right place?"* — a pattern that forms after a real liquidity grab, in the correct half of the dealing range, is graded higher; one firing into opposing liquidity is withheld. Shape alone cannot tell you location.
- **Regime** (efficiency ratio) conditions trust: a family's edge is measured separately in trend vs chop, because the same shape behaves differently in each.
- **Calibration** closes the loop: per-family, per-regime hit-rate versus an unconditional directional base rate, recency-weighted, with Wilson 95% intervals — so reliability is *earned on this instrument*, not claimed.
The skeleton says **what**, the analogs say **how it resolved before**, SMC says **whether the location is right**, the grade **fuses** them, and calibration keeps the whole thing **honest**. Remove any layer and the read loses a dimension it cannot recover.
## How it works (mechanics)
On bar close, the PIP skeleton is extracted and matched by DTW k-NN to the analog memory. The consensus direction and probability, plus the single nearest analog's forward path (the **ghost overlay**), are drawn. The pattern is graded **A/B/C** from the calibrated probability + quality + sweep + location, and gated by a minimum grade and a location veto. Every directional emission locks entry and ATR, tracks MFE/MAE in R, and at the horizon records a win if the close moved the chosen ATR multiple in its direction — feeding both the analog memory and the per-family/per-regime calibration tables.
Detection, drawing and resolution happen **on bar close over closed bars only** — no `request.security`, no dynamic-length `ta()`, no intrabar revision. Patterns are drawn once and never moved.
## How to use
1. Read the dashboard: the active pattern's **analog probability**, its **A/B/C setup grade**, **sweep validation** and **premium/discount location**.
2. Favour higher grades — a calibrated-positive family, sweep-validated, in the correct half of the range, with the ghost pointing your way.
3. Check **"This family"** — the regime-conditional and recent hit-rate is the number that matters *now*; the Pro table lists every family with Wilson confidence intervals.
4. The **ghost** shows the single closest historical precedent; the **target** is the analog mean.
5. Everything here is descriptive, probabilistic context — never an instruction.
## Use on any market
Works on any symbol and timeframe. The **Data Source** inputs (High / Low / Close) drive the entire engine — PIP skeleton, pivots, liquidity, premium/discount — from any series, so you can run it on standard candles, Heikin-Ashi, or another instrument. All thresholds are **ATR-relative**, the detection window is **cycle-adaptive**, and the analog memory and calibration rebuild **per instrument** — nothing is hard-coded to a price scale or a single market. Defaults are set for NIFTY index-futures intraday; change the sources or lengths for other assets.
## Credits
This engine builds on established, published concepts:
- **Perceptually Important Points** — Chung, Fu, Luk & Ng
- **Dynamic Time Warping** — Sakoe & Chiba
- **Homodyne-discriminator dominant cycle / adaptive windows** — John F. Ehlers
- **Efficiency Ratio** (trend vs noise) — Perry Kaufman
- **Wilson score confidence interval** — Edwin B. Wilson
- **Liquidity, premium/discount and order-block context** — smart-money / auction-market concepts (Wyckoff lineage; popularised in the ICT body of work)
The empirical analog loop (label-by-outcome DTW matching), the SMC location-grading, and the per-family/per-regime Wilson-bounded calibration framework are the author's original implementation.
## Originality
The contribution is the **closed loop**, not the objects: empirical DTW analog matching (label by outcome, not by template), SMC location-grading, and per-family/per-regime Wilson-bounded calibration, fused into one self-prioritising read with a nearest-precedent ghost overlay. The shape is only the index into history.
## Limitations (honest)
The analog memory and calibration are **in-sample, close-to-close at a fixed horizon, with no costs, slippage or stops** — a study aid, not a backtest, and not a probability of future results. The engine needs to build memory before it leaves bootstrap (watch the "Analog mem" counter). Volume-derived quality degrades on symbols without real volume. Past behaviour of a pattern does not assure future behaviour.
## Disclaimer
Educational / informational study for chart analysis only. **NOT financial advice, NOT a strategy, NOT a recommendation.** It places no orders and guarantees no outcome. Markets carry risk; do your own research and manage your own risk. Paper-trade before risking real money.
อินดิเคเตอร์
















