AG Pro Trend QualityAG Pro Trend Quality
Overview / What it does
The "AG Pro Trend Quality" script is a quantitative analysis tool designed to evaluate market momentum and directional strength, classifying price action into two primary regimes: TREND and CHOP. Its main output is an on-chart analytical panel that displays the current market regime, a normalized Trend Quality Score (0-100), market direction, and Multi-Timeframe (MTF) alignment. The script aims to help users filter out low-probability environments and visualize macro-trend continuation without cluttering the primary chart interface.
Unique Edge (Why it is not a basic mashup)
This script is not a simple combination of standard moving averages or raw indicators. It introduces a composite scoring model that normalizes three distinct market dimensions into a unified 0-100 scale: directional momentum (via ADX), price efficiency (via Kaufman's Efficiency Ratio logic), and the rate of change (via ATR-normalized EMA slope).
The unique edge lies in its gating and cooldown engine. Rather than flickering on every minor price fluctuation, the system requires a sustained threshold breach, confirmed over consecutive bars, before shifting the recognized regime. Additionally, it features an adaptive UI that automatically reduces visual data lines during non-trending (CHOP) periods to maintain absolute chart hygiene.
Methodology (Conceptual Data Flow)
Feature Extraction: The script calculates raw values for Directional Movement, Price Efficiency (step-vs-distance), and EMA Slope.
Normalization: These raw values are strictly bounded and normalized to a 0.0 – 1.0 scale using mathematical constraints.
Scoring: The normalized features are combined using a weighted formula (45% ADX, 35% ER, 20% Slope) to generate the final Trend Quality Score.
Filtering & Gating: A score above the user-defined threshold triggers a TREND candidate. Hysteresis bands (±3 points) prevent rapid toggling around the threshold level. State changes are subject to a user-defined bar-count confirmation and a secondary cooldown timer to ensure stability.
MTF Confirmation: The script can dynamically check a Higher Timeframe (HTF) for trend alignment. If the HTF is recognized as CHOP, the Lower Timeframe (LTF) trend is strictly designated as "BLOCKED".
Signals and Alerts
All alerts are deterministically defined based on strict mathematical conditions. For optimal stability, alerts should be configured to trigger on "Once Per Bar Close".
TQ: CHOP -> TREND: Triggers precisely when the final filtered regime state shifts from 0 to 1.
TQ: TREND -> CHOP: Triggers when the filtered regime state shifts from 1 to 0.
TQ: Strong Trend: Triggers when the regime is TREND and the underlying score exceeds the threshold + user-defined "Strong Offset".
TQ: HTF Blocked / Unblocked: Triggers specifically when the Multi-Timeframe gating status changes state.
Limitations & Transparency
This script utilizes request.security() to fetch Higher Timeframe (HTF) data for the MTF confirmation feature. While barmerge.lookahead_off is explicitly used to prevent repainting, historical HTF visuals may exhibit slight variances compared to real-time execution due to the inherent nature of TradingView's data feed updates. Intrabar alert triggers are not recommended; always wait for the bar close for final regime confirmation.
What It Is Not & Risk Disclosure
This indicator is not a standalone trading strategy, not an automated bot, and does not provide buy or sell recommendations. There is no such thing as a guaranteed win rate or a perfect indicator. Not financial advice. Past performance is not indicative of future results. Do your own research and testing.
Pine Script® インジケーター






















