Double Top / Bottom Quality [AGPro Series]Double Top / Bottom Quality
Double Top / Bottom Quality is a disciplined, rules-based detector for the two most iconic reversal chart patterns: the Double Top (M-shape) and the Double Bottom (W-shape). Unlike basic pattern finders that fire on any two similar swings, this indicator scores every candidate pattern on a transparent 0–100 Quality Score across four independent factors — and only confirms patterns that pass a user-defined minimum. The result is a cleaner chart with fewer, higher-conviction setups.
Every confirmed pattern delivers a full trading lifecycle: a neckline flip S/R zone (resistance → support on a Double Bottom; support → resistance on a Double Top) and a measured-move target projection band. Pending, confirmed, target-hit and invalidated states are all tracked with disciplined cleanup, so the chart never becomes cluttered.
🔹 WHAT THE INDICATOR DOES
It detects classic Double Top and Double Bottom reversal structures using pivot-based swing analysis with ATR-normalised equality, depth and time-window filters. Each valid candidate is then scored on four independent quality factors. Only candidates that exceed the user-defined minimum score and break the neckline on close are confirmed. Once confirmed, the pattern draws its neckline flip zone and target projection band, labels the setup with its letter grade and score, and tracks the outcome until target hit or invalidation.
🔹 UNIQUE EDGE — WHY IT IS DIFFERENT
Most Double Top / Double Bottom scripts simply connect two similar swings and draw a line. This indicator adds a transparent 4-component Quality Score so every setup is rated before confirmation, not just flagged. Three factors that most scripts ignore are treated as first-class inputs here:
• Pattern Symmetry — the left leg and the right leg of the M / W must be comparable in time, or the pattern is penalised
• Break Volume Confirmation — the neckline break bar is compared to its rolling volume average, and thin breaks score lower
• Depth Quality — shallow, flat patterns are filtered out in favour of deep, decisive reversals
The full lifecycle visualisation (pending → confirmed → target hit) and same-region deduplication are also uncommon in this pattern category, and together they produce a chart that reads cleanly even on long history.
🔹 METHODOLOGY
• Pivot detection via ta.pivothigh / ta.pivotlow with user-configurable length
• Equality check: the two peaks (or troughs) must be within a configurable ATR tolerance
• Time-window filter: minimum and maximum bars allowed between the two pivots
• Depth filter: the vertical distance from peaks to neckline must exceed a minimum ATR threshold
• Neckline: lowest low between the two peaks for a Double Top, or highest high between the two troughs for a Double Bottom
• Confirmation trigger: daily close beyond the neckline
• Invalidation: price exceeds the pattern extreme before the neckline break
• Cooldown: after confirmation, new patterns in the same price region are suppressed for N bars to prevent clustering
🔹 QUALITY SCORE (0–100)
Each confirmed pattern receives a transparent score based on four equally-weighted factors (25 points each):
1. Peak / Trough Equality — how close the two extremes are to each other, measured in ATR units
2. Break Volume Confirmation — break-bar volume relative to the 20-bar average
3. Pattern Symmetry — ratio of the shorter leg to the longer leg (time-based)
4. Depth Quality — pattern height relative to ATR (deeper = higher score)
Score → Grade mapping:
• 85–100 = A
• 70–84 = B
• 55–69 = C
• <55 = D
🔹 SIGNALS, ZONES & ALERTS
Once a pattern confirms, the indicator renders:
• A solid neckline that extends to the right edge
• A neckline flip zone (rectangular S/R band at the neckline level)
• A target projection zone at the measured-move price (pattern height projected from neckline)
• A grade label (A / B / C) and numeric score on the pattern
Two alert types are available: "Confirmed Pattern" fires on confirmation, and "Target Hit" fires when the measured-move target is reached.
🔹 KEY INPUTS
• Pivot Length, ATR Length
• Peak / Trough Equality tolerance (ATR)
• Min / Max bars between peaks
• Minimum Pattern Depth (ATR)
• Break Volume Multiplier
• Cooldown bars
• Minimum Quality Score filter
• Show Pending Patterns toggle
• Show Neckline Flip Zone / Target Zone toggles
• Zone Width (ATR)
• Stale Cleanup Distance, Max Active Zones
• Label size, Panel position / theme / size
• Alert toggles
🔹 HOW TO USE
• Choose a liquid market and a timeframe that matches your trading style (4H and 1D are particularly well-suited to classic reversal patterns)
• Watch for Pending patterns (dashed lines) — these mark candidates awaiting a neckline break
• A Confirmed pattern with grade B or higher is the typical entry signal; aggressive traders may use C-grade while conservative traders may filter to A-grade only
• Use the neckline flip zone as a logical stop-loss reference (above it for Double Tops, below for Double Bottoms)
• Use the target projection zone as a take-profit reference based on the classical measured-move rule
• Combine with higher-timeframe trend, volume profile or an independent confluence tool for best results
🔹 LIMITATIONS & TRANSPARENCY
• Pivot-based detection means patterns confirm with a natural lag equal to the pivot length
• No strategy is 100% reliable — Quality Score filters improve average conviction but do not guarantee outcomes
• Very low-liquidity markets may produce unstable pivots; a longer pivot length helps
• Measured-move targets are a classical reference, not a prediction
• Historical statistics shown in the panel are pattern-completion counts on the loaded chart; they are not a guaranteed forward performance estimate
🔹 RISK DISCLOSURE
This script is provided for educational and analytical purposes only. It is not financial advice and does not constitute a recommendation to buy, sell or hold any asset. Trading involves substantial risk of loss; past pattern performance is not indicative of future results. Always perform your own research and use appropriate risk management.
Open-source under the Mozilla Public License 2.0 — contributions and feedback are welcome.
Indicador Pine Script®











