Skip to content
✎ FeedbackNew here?
Open the Harmonic scanner →the live surface this page describes — data, filters and history
How well testedDescriptive onlyit describes what happened; it has never earned the right to rank or selectRecorded: LIVE (descriptive) · backtest-GATED

Harmonic Patterns (XABCD / PRZ) — Canonical Reference

One-line definition: Harmonic patterns are five-point (X-A-B-C-D) price structures whose leg lengths match a named Fibonacci-ratio template (Gartley· Bat· Butterfly· Crab· Deep Crab), completing at a D-point inside a Potential Reversal Zone (PRZ) where the prior swing is expected to reverse.


1. What it is

A harmonic pattern reads a run of price as five alternating swing pivots — X → A → B → C → D — and asks whether the four legs between them fall into the Fibonacci proportions of a named pattern. When they do, the D-point marks a Potential Reversal Zone (PRZ): the price cluster where the pattern "completes" and the market is expected to turn. Direction is read off D — a D that prints a swing low is BULL (reverses up); a D that prints a swing high is BEAR (reverses down).

Our implementation surfaces two states:

It is a geometry / selection lens, not a trading trigger. Detection is the cheap part; whether any pattern × timeframe carries a real forward edge on our universe is a separate, backtest-gated question (§4).

2. Our variation vs. the standard technique

Standard harmonic trading (Gartley/Scott Carney lineage) is a manual, discretionary craft: an analyst eyeballs an XABCD, drops Fibonacci retracement/extension tools on the legs, and trades a reversal off the PRZ. Ratios, tolerances, and which patterns "count" vary by author.

Our variation turns that into an automated, mechanized, universe-wide scanner with an explicit honesty gate:

Where it sits in the stack: it is one lens in the charting overhaul (the "CPR Spine" chart), a sibling to the Wolfe Wave lane — it reuses Wolfe's pivot machinery read-only and draws onto the same shared candle chart as an optional overlay chip, so CPR / Accumulation / MA / RS / Wolfe all coexist with it.

3. How it works (methodology)

daily OHLC (NSE bhav, split-adjusted)
 │ (optional W/M resample — resample_series)
 ▼
ATR-zigzag pivots ──(reused read-only from the wolfe code)──► alternating H/L swings
 ▼
slide a 5-pivot window (X,A,B,C,D)
 ▼
structure gate → leg ratios AB· BC· CD· AD → match to a named template (all 4 bands)
 ▼
 ┌── CONFIRMED (D locked) → fit score, RSI at D, direction from D
 └── FORMING (X-A-B-C, no D) → project PRZ = cluster of candidate D levels

1. Pivot / swing detection. stock_series builds a split-adjusted OHLC series; ATR-zigzag (or fractal) reduces it to alternating swing highs/lows — the same primitives the Wolfe lane uses. 2. XABCD legs. For each consecutive 5-pivot window a structure gate enforces strict H/L alternation and the monotonic frame (B is a real XA retrace, C sits between, D is the turn), then the four leg ratios are computed: AB, BC, CD, and AD — where AD (D's position vs the XA leg) is the defining ratio. 3. Fib-ratio matching. Each candidate is tested against every template's acceptance bands; a match requires all four bands at once (the ratios are mutually constrained, which is what forces a real pattern). The best-fitting template wins, scored by mean closeness to its ideal AB/CD/AD. 4. PRZ projection (forming). For an in-progress X-A-B-C, only templates whose AB the leg already satisfies can still complete; each projects a candidate D from its AD ratio, and the cluster of those levels becomes the PRZ (lo/hi/mid).

Ratio constants are NOT restated here. They live in code (HARMONICS in the harmonic patterns code) and, illustratively, in the harmonic pattern design notes If the two ever disagree, code is authoritative (a couple of AD bands were widened slightly in code vs the design table — see §8).

4. Status, validation & honesty fence

LIVE but DESCRIPTIVE and backtest-GATED. The scanner and the chart overlay are in production; the edge claim is not. Consistent with project doctrine, the harmonic lens is a SELECTION shape — tail-carried, not a validated fundable book (the same characterization the strategy ledger applies to Wolfe/Ignition, and that PEAD-delivery was grouped into).

The reliability gate (the harmonic backtest code, run 2026-06-28 on a survivorship-inclusive universe, 1,052 confirmed patterns, entry lagged 5 bars after D, signed by reversal direction, vs same-horizon directional drift) found:

The full result table and per-pattern breakdown live in the harmonic pattern design notes — this page links rather than restates.

Honesty fence (binding):

5. Where it lives (code· routes· DB· timers)

Code (all NEW, harmonic-lane-owned; reuse the wolfe code READ-ONLY):

FileRole
the harmonic patterns codeDetector — ratio-template library, per-type validator, structure gate, forming-PRZ projection, D/W/M resample, selftest.
the harmonic signals codeScanner + nightly-persisted harmonic_signals snapshot (scan / persist_scan / latest).
the harmonic backtest codeReliability gate — survivorship-inclusive forward-outcome backtest vs directional drift.
the harmonic view code/dash/harmonic scanner page + /dash/harmonic/overlay JSON feed.
the stock chart code (shared)The Harmonic chip — draws each pattern's X-A-B-C-D polyline + point markers + the forming PRZ band on the candle chart (window.__wfpc, autoscale-opt-out).
scripts/hermes-harmonic-scan.{service,timer}Nightly persist unit.

Reused from the wolfe code (read-only): zigzag, atr, fractal_pivots, stock_series, rsi, scan_universe, Pivot.

Routes:

DB: table harmonic_signals — module-owned (CREATE-IF-NOT-EXISTS inside the harmonic signals code; the db code / SCHEMA_BASE untouched, same isolation pattern as Wolfe's wolfe_signals). Columns: universe, sym, pattern, dir, state (CONFIRMED|FORMING), score, cmp, d_price, prz_lo, prz_hi, in_zone, rsi_d, age, tag (edge|tail), scan_date, computed_at. Written as a clean per-universe snapshot (DELETE-then-INSERT); indexed on (universe, in_zone DESC, age ASC).

Timer: hermes-harmonic-scan.timer runs python -m src.automation.harmonic_signals --persist-scan nightly Mon–Fri 16:10 UTC (after bhav → signals and the Wolfe scan). No LLM in the scheduled path (Guardrail #3 compliant).

6. Data & provenance

7. Terminology canon

Disambiguation — Harmonic vs. Wolfe Wave. Both are five-point geometries built on the same pivot engine, but they are different techniques: Wolfe Wave is defined by trendline/channel symmetry and an EPA (estimated price & arrival) target line; Harmonic is defined by Fibonacci leg-ratio templates + a PRZ. Do not conflate the two. See the sibling canonical reference: the wolfe wave notes.

8. Decision & session history

9. Open items / frozen work

10. Sources of truth