OPEN-SOURCE SCRIPT
Updated

AG Pro Pin Bar Quality Filter [AGPro Series]

2 060
AG Pro Pin Bar Quality Filter [AGPro Series]

Overview / What it does

AG Pro Pin Bar Quality Filter is a price-action overlay built to detect pin bar candles and then separate higher-quality rejection candles from weaker or noisier ones.

The script does not treat every long-wick candle as equally meaningful. Instead, it evaluates the internal candle structure first, then applies a compact quality framework around volume, recent momentum, and local support/resistance context. The result is a filtered pin bar workflow designed for traders who want cleaner chart annotation rather than a raw pattern dump.

This tool focuses on one specific job: identifying rejection candles with a measurable structure and presenting them with a readable quality label directly on the chart. It is intended to help users inspect potential reaction points, not to replace broader market context or execution rules.

The visual design is intentionally simple at the core: pin bar body highlighting, wick emphasis, directional markers, and compact quality labels. This makes the script suitable for traders who want candle-based context without converting the chart into a full market-structure dashboard.

Unique Edge

The distinctive feature of this script is that it does not stop at pattern detection.

A standard pin bar script often marks candles only because they have a long wick. This script goes further by checking whether the wick is large enough relative to the body, whether the body itself is small enough relative to the full candle range, and whether one wick clearly dominates the other. That combination helps reduce ambiguous candles that visually resemble pin bars but do not express clean rejection.

After the structural test, the script applies a three-part quality model:
- volume confirmation
- momentum context
- support/resistance proximity

This creates a practical quality hierarchy rather than a binary pattern label. In other words, the script is not only asking “Is this a pin bar?” but also “How much contextual support does this pin bar have?”

An optional piercing check is also available for users who want stricter validation. This adds another layer of selectivity by requiring the candle body to show stronger positional behavior relative to the prior bar.

Methodology

The script starts by measuring the current candle:
- candle body size
- full candle range
- upper wick length
- lower wick length
- dominant wick versus body ratio

A raw pin bar candidate requires:
- a minimum wick/body ratio
- a maximum body percentage of full range
- directional wick dominance

This helps define whether the candle is a legitimate bullish or bearish rejection structure.

Bullish pin logic is based on lower-wick dominance.
Bearish pin logic is based on upper-wick dominance.

Once a raw pin bar is detected, the script evaluates three contextual filters.

1) Volume filter
The current volume can be compared against a moving average of volume. This helps identify candles that form with relatively stronger participation.

2) Momentum confirmation
The script can check whether recent candles were moving in the opposite direction of the current pin bar. For example, a bullish pin bar becomes more meaningful when it forms after short-term downward pressure, while a bearish pin bar becomes more meaningful after short-term upward pressure.

3) Support / resistance proximity
The script tracks pivot-based reference levels and checks whether the pin bar forms close to a recent local support or resistance area, using an ATR-based distance threshold.

Each passed filter contributes to the final quality score. This produces a compact tiered output instead of a single undifferentiated signal stream.

Signals & Alerts

The script can identify:
- bullish pin bars
- bearish pin bars
- higher-quality pin bars based on the selected minimum score

Visual elements may include:
- body highlighting on detected pin bars
- wick emphasis
- directional arrow markers
- quality labels with contextual details
- an information panel summarizing the active state

The quality label can display the signal tier and relevant confirmations such as:
- wick/body ratio
- volume confirmation
- momentum confirmation
- support/resistance proximity

Alert conditions are available for:
- bullish pin bars
- bearish pin bars
- prime-quality pin bars
- any valid pin bar that meets the selected score threshold

This allows users to align alerts with their own strictness settings rather than monitoring every possible candle manually.

Key Inputs

Important user controls include:
- minimum wick/body ratio
- maximum body percentage of full range
- wick dominance threshold
- optional piercing requirement
- volume filter enable/disable
- momentum filter enable/disable
- support/resistance filter enable/disable
- minimum quality score
- label size
- panel display
- maximum number of displayed signals

These settings make the script adaptable across different instruments and chart styles. Users who prefer a broader scan can lower the strictness, while users who want fewer but cleaner signals can raise the thresholds.

Limitations & Transparency

This script is a rule-based candle-quality filter. It is not a market prediction engine, and it does not attempt to classify broader trend structure, liquidity behavior, or macro regime by itself.

A pin bar can still fail even when all filters pass. A visually strong rejection candle is not automatically a durable reversal. Context such as higher-timeframe structure, trend state, volatility regime, session behavior, and instrument-specific character still matters.

Support and resistance detection in this script is pivot-based and proximity-based. It is designed as a practical contextual filter, not as a complete structural mapping model.

Volume behavior also varies by asset and market type. On some instruments, especially where centralized volume data is limited or interpreted differently, the volume filter should be treated as a supplementary input rather than a universal truth test.

The momentum check is intentionally compact and local. It is meant to improve candle context, not to replace broader directional analysis.

For these reasons, the script is best used as a chart-reading assistant within a larger process, not as a standalone decision framework.

Risk Disclosure

This script is provided for technical analysis and chart annotation purposes only.

It highlights selected pin bar conditions based on user-defined structural and contextual rules. It does not provide financial advice, investment advice, or guaranteed trade outcomes. Markets can remain irrational, trend continuation can invalidate rejection candles, and false positives can occur in all timeframes and asset classes.

Users should validate the script on their own instruments, timeframes, and risk models before relying on it in live conditions. Position sizing, stop placement, execution discipline, and overall trade management remain the responsibility of the user.

In summary, AG Pro Pin Bar Quality Filter is designed to help traders study rejection candles with more structure, more selectivity, and cleaner on-chart presentation than a basic pin bar marker, while remaining transparent about what the script does and does not do.
Release Notes
Update Notes - V1.5

This update focuses on chart readability, cleaner visual balance, and a more selective default presentation.

What changed

• Reworked the default display density to reduce label crowding on chart.
• Balanced the default view so Strong and Prime signals remain visible without overwhelming price action.
• Tightened signal spacing logic to reduce repeated nearby labels of the same type.
• Improved global label distribution so the chart stays easier to read across active zones.
• Refined label offset behavior for a cleaner separation between candles and signal boxes.
• Kept Prime signals visually distinct while maintaining a more compact overall layout.
• Preserved the blue single-row merged panel header for a cleaner AG Pro panel identity.
• Maintained Small as the default panel font size and Normal as the default label font size.
• Improved the general 1H to 4H visual presentation so the script reads more cleanly in practical chart use.

Design intent

The goal of this revision is not to show more objects, but to show the more useful ones more clearly. The updated default view is designed to reduce noise, preserve structure, and make the chart easier to interpret at a glance.

What did not change

• The script still evaluates pin bars through its existing quality framework.
• Volume, momentum, and S/R-related filtering logic remain part of the quality model.
• This update is mainly centered on presentation, visibility, and chart usability.

Transparency

This script highlights pin bar conditions based on its internal rules and user-defined settings. It does not predict future price direction and should be used as a chart analysis tool, not as a standalone trading decision engine.

Risk disclosure

This script is for analysis and educational use only. All signals should be reviewed in context with market structure, liquidity conditions, higher-timeframe bias, and personal risk management.
Release Notes
Update Notes - Version 2.0

This update keeps the script focused on pin bar rejection quality while giving it a cleaner, richer, and more premium chart presence.

- Rebuilt the public title into the latest AGPro naming standard while keeping the panel title branded.
- Added Rejection Memory Zones so strong pin bars can project a compact forward reaction area instead of disappearing after a single label print.
- Added a Directional Close filter to keep bullish pins finishing high in range and bearish pins finishing low in range.
- Added a Range Expansion filter so tiny candles with long wicks do not dominate the chart.
- Kept the core context model anchored to volume, short-term momentum, and pivot proximity instead of drifting into a separate liquidity sweep or break-retest script family.
- Refined label spacing, signal throttling, and wick emphasis so the chart stays active but still reads like a premium publication.
- Rebuilt the info panel around the AGPro palette with the required merged blue first row, adjustable location, adjustable theme, and Normal-sized font defaults.
- Cleaned the full script into English-only public-release formatting with professional tooltips and no extra license boilerplate.

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.