OPEN-SOURCE SCRIPT
Updated

AG Pro Reversal Pattern Quality Scanner [AGPro Series]

1 637
AG Pro Reversal Pattern Quality Scanner [AGPro Series]

Overview / What it does

AG Pro Reversal Pattern Quality Scanner is an overlay tool designed to detect and visualize selected classical reversal structures directly on the chart while adding a structured quality layer to each valid setup. The script focuses on four widely recognized reversal formations: Double Top, Double Bottom, Head & Shoulders, and Inverse Head & Shoulders.

Instead of marking every possible structural resemblance, the script applies a filtered detection workflow based on pivot structure, pattern width, peak or trough equality, pullback depth, neckline logic, and an internal quality model. The goal is not simply to identify a shape, but to highlight formations that display more balanced structure and more usable context.

Each detected pattern can be displayed with a pattern box, a projected neckline, and a quality label that summarizes the pattern type, directional bias, quality score, and grade. This makes the script suitable for traders who want a structured visual map of potential reversal zones rather than a raw pattern-highlighting tool with no ranking logic.

The indicator is built for chart reading and workflow support. It does not attempt to forecast future price movement with certainty, and it should not be interpreted as a standalone trade system. Its role is to help users organize reversal structures, compare them visually, and focus on higher-quality formations when reviewing price action.

Unique Edge

The main distinction of this script is that it does not treat all reversal patterns as equivalent. A detected pattern is further evaluated through a composite quality framework that considers structural symmetry, pullback depth, and volume behavior during formation and break conditions.

For Double Top and Double Bottom structures, the script checks whether the two peaks or troughs remain sufficiently close to each other within a defined tolerance and whether the intermediate pullback is large enough to make the structure meaningful. For Head & Shoulders and Inverse Head & Shoulders structures, the script evaluates shoulder symmetry, time symmetry, and relative positioning of the head against the shoulders.

The volume component is not used as a promise of confirmation. It is used as an additional contextual factor inside the quality score. In general terms, contracting volume during formation and stronger participation during the break candidate can improve the overall score when those conditions are present.

Another important part of the design is visual prioritization. The script does not only draw the structure. It also attempts to keep the chart readable by organizing labels, neckline extensions, and pattern boxes in a way that preserves interpretation. The result is a cleaner reversal-pattern map that aims to be more practical than a simple shape detector.

Methodology

The script begins with swing pivot detection. These pivots act as the structural foundation for all pattern candidates. Once enough pivot highs and lows are available, the script evaluates whether recent pivot sequences fit the requirements of one of the supported reversal structures.

For Double Top detection, the script checks whether two recent highs are similar enough, whether the interim low forms a valid neckline reference, whether the pattern width stays within defined limits, and whether price has broken below the neckline. For Double Bottom detection, the logic is mirrored on the bullish side through two similar lows, an interim high as the neckline reference, and a bullish break condition above that neckline.

For Head & Shoulders detection, the script evaluates a sequence of three pivot highs where the middle high must exceed the two shoulders. It then estimates neckline structure from the lows between those highs and applies symmetry and pullback checks before accepting the setup. Inverse Head & Shoulders applies the same structural concept in reverse using pivot lows.

After a valid break condition is detected, the script calculates a composite quality score. This score is based on user-controlled weights for volume behavior, symmetry, and pullback depth. The final output is normalized into a 1 to 10 quality scale, then translated into a grade label for easier scanning.

Signals & Alerts

The script can generate pattern-based alert conditions for:
- Double Top
- Double Bottom
- Head & Shoulders
- Inverse Head & Shoulders

These alerts are tied to the script’s internal structural conditions and neckline break logic. As with any chart-based alert workflow, users should confirm that the selected settings match their market, timeframe, and execution style.

Visual output can include:
- Pattern boxes
- Neckline lines
- Neckline labels
- Pattern quality labels
- Break candle highlighting
- Information panel with detection statistics

The quality label is intended to summarize the detected structure, not to guarantee outcome quality. A higher score means the pattern aligned more closely with the script’s internal criteria. It does not mean the setup must succeed.

Key Inputs

The script includes adjustable inputs for both detection behavior and presentation. Key controls include:
- Swing Pivot Length
- Peak / Trough Equality tolerance
- Minimum Pullback Between Peaks or Troughs
- Minimum and Maximum Pattern Width
- Minimum Quality to Display
- Weighting of volume, symmetry, and pullback depth inside the quality score
- Box, neckline, and pattern-label visibility
- Global label size
- Panel font size
- Panel position
- Neckline extension length
- Pattern-specific alert toggles

These controls make it possible to adapt the scanner to different chart densities, volatility profiles, and personal visual preferences.

Limitations & Transparency

This indicator is a rule-based pattern scanner. It is not a predictive engine, and it does not claim that all detected formations will lead to continuation or reversal. Classical chart structures can fail, invalidate, or behave differently depending on volatility, trend strength, liquidity conditions, timeframe, and broader market context.

Pattern recognition on live charts is inherently sensitive to pivot settings and bar structure. Small changes in pivot length, equality tolerance, or minimum pullback can materially change how many formations appear. Because of that, users should treat the script as a configurable analytical framework rather than a universal template.

The quality score is an internal ranking model built from the script’s own criteria. It is meant to help compare setups inside the same framework. It should not be interpreted as an objective probability model, a performance promise, or a substitute for independent trade management.

Volume analysis also depends on the reliability and characteristics of the symbol’s reported data. On some instruments, volume may be less informative or behave differently than expected. Users should evaluate this in the context of their own market.

Risk Disclosure

This script is provided for chart analysis, workflow organization, and educational use. It does not provide financial advice, investment advice, or guaranteed trade signals. All trading and investment decisions remain the sole responsibility of the user.

Reversal patterns can fail even when they appear clean and well-structured. Breaks can reverse, neckline moves can trap participants, and high-scoring formations can still underperform. Risk management, confirmation process, position sizing, and overall strategy design remain essential.

Use this tool as a structured visual aid inside a broader decision-making process, not as a standalone reason to enter or exit a position.
Release Notes
Update Notes - V1.1

This update refines the presentation layer, expands the quality model, and improves signal control for a cleaner chart workflow.

What changed in Version 1.1

- Reworked the info panel to match the current AG Pro visual standard.
- Updated the panel header into a single merged first row with the script name only.
- Adjusted the default panel font size to Small for a cleaner footprint.
- Kept label sizing aligned with the dedicated label size setting.
- Added breakout strength as an additional quality component.
- Added ATR-based neckline break confirmation for stricter validation.
- Added optional breakout volume confirmation.
- Added same-type signal cooldown logic to reduce repetitive pattern triggers.
- Added a display window control to better manage visible pattern density.
- Added a neckline label visibility toggle.
- Added a break arrow visibility toggle.
- Added an optional A-grade-only filter for users who want stricter visual selection.

Notes

- This script is designed for pattern detection, chart organization, and alert support.
- Pattern quality values are internal scoring outputs derived from the script logic and inputs.
- Signals and scores should be interpreted within the broader chart context.
- This update focuses on readability, filtering, and structural confirmation rather than prediction.

Risk Disclosure

This script is for market analysis and educational use only. It does not guarantee outcomes and should not be treated as financial advice.
Release Notes
Update Notes - Version 2.0

- Rebuilt the script into a cleaner multi-pattern scanner so overlapping reversals are filtered with same-region deduplication instead of stacking on the same chart zone.
- Added projected Retest Pocket Zones around confirmed neckline breaks to keep the most actionable reaction area visible after confirmation.
- Upgraded the quality model with stronger structural balance checks, breakout strength scoring, volume behavior analysis, and exhaustion-context scoring.
- Improved label spacing, density control, and break tags so the chart stays premium and readable on busy markets.
- Refreshed the scanner panel with AGPro styling, theme control, movable positioning, and the standard merged blue header row.
- Updated the public title format to remove the leading AG Pro tag while keeping AG Pro inside the panel identity.

Disclaimer

The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.