OPEN-SOURCE SCRIPT
Mis à jour

AG Pro MACD Drift Filter [AGPro Series]

1 118
AG Pro MACD Drift Filter [AGPro Series]

Overview

AG Pro MACD Drift Filter is a rules-based momentum quality indicator built around MACD structure, persistence, and decay behavior.

The script is not designed to treat every MACD expansion, crossover, or positive histogram print as equally meaningful. Its purpose is to help users evaluate whether current momentum is sustaining cleanly, weakening internally, or drifting into lower-quality continuation.

In many charts, the difficult part is not detecting that momentum exists. The difficult part is deciding whether that momentum is stable enough to respect, fragile enough to fade, or already starting to lose transmission quality before price fully reflects the slowdown. This indicator is built for that specific problem.

Rather than framing MACD as a simple signal engine, AG Pro MACD Drift Filter uses a structured state model to organize momentum into practical categories such as bullish drift, bearish drift, neutral or unstable conditions, and decay-prone phases. The output is intended to improve chart interpretation, not to replace broader market context.

What the script does

The script studies the relationship between the MACD line, the signal line, the histogram, and zero-line behavior in order to classify the current momentum environment.

Its main objective is to answer questions such as:

- Is current momentum expanding with acceptable continuity?
- Is the histogram improving in a way that supports follow-through, or only producing a temporary burst?
- Is MACD maintaining stable directional structure, or repeatedly slipping back toward unstable conditions?
- Is separation between MACD and signal line supporting continuation, or beginning to compress?
- Is the current move still carrying directional quality, or transitioning into decay?

The result is a compact momentum-quality framework that can be used as a continuation filter, a caution filter, or a chart-organization layer.

Why this script is different

This script is not presented as a generic MACD crossover tool.

Its focus is not on counting crosses or highlighting every histogram color shift. Instead, it is built around the idea that momentum quality matters more than raw momentum presence. A move can remain above zero and still lose internal quality. A histogram can expand and still produce weak follow-through. A crossover can occur inside unstable conditions and carry less analytical value than its appearance suggests.

AG Pro MACD Drift Filter attempts to separate those cases by combining several dimensions of MACD behavior into a rules-based drift model.

In practical terms, the script attempts to distinguish between:

- sustained directional drift
- fragile continuation
- internal weakening
- contraction and decay risk
- unstable zero-line behavior

This makes it more suitable as a momentum filter than as a standalone trigger engine.

Core methodology

The model evaluates momentum quality through multiple components rather than a single event.

1) Expansion quality

The script evaluates whether histogram magnitude is expanding with enough consistency to support the idea of directional development. A simple increase in histogram size is not treated as sufficient on its own. The model also looks at whether that expansion is steady enough to qualify as usable drift.

2) Zero-line persistence

Momentum states near the zero line can be more fragile and more prone to whipsaw. For that reason, the script evaluates whether MACD is maintaining enough distance and persistence relative to the zero area, or whether it is repeatedly slipping back toward instability.

3) Signal-line separation quality

The distance between MACD and signal line is part of the script's continuation logic. Expanding separation can support the case for cleaner momentum conditions, while compressing separation can indicate that the move is losing internal pressure even if price has not fully reacted yet.

4) Continuity

The script tracks whether directional alignment is being maintained across bars. The goal is to reduce the analytical weight of fragmented or inconsistent momentum states and give more weight to cleaner persistence.

5) Decay pressure

The model also monitors conditions that can reduce the quality of current drift. Compression, weakening histogram behavior, increased instability, and loss of directional efficiency contribute to decay risk.

These components are combined into a structured quality score and a state engine.

Main outputs

State

The State row summarizes the current momentum regime. Depending on conditions, the script can classify the environment as bullish drift, bearish drift, neutral or unstable, or other transition states derived from the internal logic.

Quality

The Quality value summarizes the current momentum-quality condition on a 0 to 100 scale. It is not intended as a standalone trade score. It is a compact way to express whether the underlying drift structure is currently weak, fragile, usable, or stronger relative to the script's framework.

Persistence

Persistence reflects whether directional conditions are being maintained with enough stability to be respected. This value is particularly useful when users want to distinguish between brief impulses and cleaner continuation behavior.

Decay Risk

Decay Risk estimates whether the move is beginning to lose quality internally. Higher decay risk does not automatically imply reversal. It means the current directional structure is carrying less internal efficiency and may deserve more caution.

Zero-Line

This field summarizes whether MACD is operating above zero, below zero, or in a more unstable zone. It is included because zero-line persistence often changes the interpretive quality of otherwise similar MACD readings.

Separation

This row describes whether MACD and signal line are expanding apart, remaining relatively stable, or compressing. It can help users identify whether momentum is gaining transmission strength or narrowing.

Phase

The script groups behavior into broad phases such as expansion, plateau, or contraction. This helps users interpret whether the current environment is still developing or beginning to cool.

Bias

Bias is not a buy or sell instruction. It is a compact interpretation layer that summarizes whether the current structure is more consistent with continuation, caution, or weaker follow-through.

Mode

The script includes a mode framework so users can run the tool with a more balanced or more selective posture, depending on how strict they want the state engine to be.

How to read the indicator

One practical way to use the script is to treat it as a continuation-quality filter.

For example, a bullish chart condition may look more structurally convincing when:

- the state remains in a bullish drift condition
- the quality score is improving or holding at healthier levels
- persistence remains stable
- separation is not compressing aggressively
- decay risk is contained

On the other hand, users may choose to become more cautious when:

- price still appears constructive, but quality is fading
- separation compresses while continuation expectations remain elevated
- the state returns to neutral or unstable conditions
- decay risk rises without meaningful renewal in quality
- the move remains active on price, but internal MACD structure begins to deteriorate

This script can also be used alongside support and resistance analysis, broader trend context, structural breaks, pullback logic, or other risk-management frameworks.

Alerts

The script includes alert conditions tied to meaningful state changes rather than arbitrary noise.

Examples include:

- Bullish Drift Confirmed
- Bearish Drift Confirmed
- Bullish Drift Weakening
- Bearish Drift Weakening
- Momentum Decay Warning
- Neutral Reset
- High-Quality Drift Detected
- Low-Quality Expansion Detected

These alerts are intended to help users monitor changes in momentum quality, not to function as guaranteed trading signals.

Key inputs

Core settings include the source series and standard MACD lengths.

Engine settings allow users to control the quality lookback, persistence window, decay sensitivity, instability penalty, zero-line stability filtering, and strictness.

Display settings manage panel visibility, panel position, theme handling, label size, label density, and optional visual styling.

Because different symbols and timeframes can produce different rhythm characteristics, users may want to experiment with persistence and sensitivity settings rather than assuming one configuration fits all market conditions.

Suggested interpretation

The strongest use case for this tool is not signal substitution, but signal qualification.

In other words, many users may find it more useful to ask:

"Does this move deserve continuation bias?"

instead of asking:

"Did MACD cross?"

That distinction is central to the script.

The script does not assume that every positive histogram bar is actionable. It does not assume that every crossover deserves equal analytical weight. It attempts to organize momentum conditions into a more structured framework so users can better judge whether current directional pressure is persistent, fragile, or fading.

Limitations and transparency

This indicator does not predict future price movement.

It does not guarantee continuation, reversal, breakout success, or trade performance. It does not replace broader chart context, volatility analysis, liquidity considerations, or risk management.

Like other momentum-based tools, it can still produce less useful readings in highly choppy environments, low-volatility compression regimes, or sudden event-driven price conditions. Users should interpret the output in context and validate whether the script's settings fit the instrument and timeframe they are studying.

The state engine is designed to organize information, not to remove uncertainty from market behavior.

Risk disclosure

This script is for educational and analytical use.

It should not be treated as financial advice, investment advice, or a promise of outcome. Users remain responsible for their own decision-making, trade planning, and risk control.
Notes de version
AG Pro MACD Drift Filter [AGPro Series]
Update Notes - V1.1

This update focuses on presentation quality, panel clarity, and cleaner drift-state communication while preserving the core behavior of the script.

What changed in this update:

• Refined the summary panel into a more compact AG Pro layout.
• Rebuilt the panel header with the standard single-row blue title format.
• Improved table readability with cleaner spacing and more balanced visual hierarchy.
• Standardized the panel for a small default font size.
• Kept state labels at a normal default size for better chart readability.
• Enhanced the visual separation between bullish and bearish drift phases.
• Improved drift-state labeling so major transitions are easier to identify.
• Smoothed the overall lower-panel presentation for a cleaner publish screenshot.
• Reduced visual clutter while keeping the main MACD drift information visible.
• Preserved the script’s original analytical purpose while improving usability and presentation.

Notes:

This script is designed to help visualize MACD drift persistence, weakening behavior, and transition quality. It is an analytical support tool and should be used as part of a broader chart-reading process.
Notes de version
UPDATE NOTES - V1.3.1

This update focuses on chart readability, cleaner state labeling, and a more refined visual presentation.

• State labels were moved onto the price chart for clearer event placement.
• Bullish labels are now positioned below price, while bearish labels are positioned above price for faster directional reading.
• Label density was reduced to keep the chart cleaner and to prioritize higher-quality state transitions.
• Label spacing was improved so labels do not get buried inside candles.
• The visual structure was refined to make the script easier to read across both higher and lower timeframes.
• Panel and label sizing remain adjustable, with Normal used as the default reading size.
• General visual cleanup and code refinement were applied for a more polished user experience.

No predictive or automated trading functionality was added in this update. The script remains an analytical tool designed to help interpret MACD drift structure, quality, persistence, and decay behavior.
Notes de version
Update Notes V1.4.0

This update focuses on publication quality, visual polish, dashboard clarity, and cleaner momentum-state communication while preserving the core MACD drift methodology.

What changed:
- Updated the public script title to the new naming standard: MACD Drift Filter [AGPro Series].
- Kept the AG Pro identity inside the dashboard header only.
- Refined the summary panel with the standard single-row blue title header.
- Added a Zero-Line context row for faster interpretation of MACD stability.
- Improved dashboard theme handling for dark, light, and automatic chart backgrounds.
- Added configurable normal-default font sizing for both the panel and price-chart labels.
- Improved label spacing, label filtering, and ATR-based label placement so labels stay readable and do not disappear into candle bodies.
- Added a maximum visible label control to keep historical charts responsive and visually premium.
- Preserved the oscillator regime boxes as the script's dedicated zone layer, avoiding overlap with separate support/resistance or supply/demand tools.
- Cleaned alert messages so they match the updated script name.
- Reduced unnecessary visual load while keeping the chart active, informative, and publication-friendly.

The goal of this version is a cleaner, more professional MACD momentum-quality workflow: strong enough for a premium screenshot, compact enough for daily use, and distinct enough to remain aligned with the original MACD Drift Filter concept.

Clause de non-responsabilité

Les informations et publications ne sont pas destinées à être, et ne constituent pas, des conseils ou recommandations financiers, d'investissement, de trading ou autres fournis ou approuvés par TradingView. Pour en savoir plus, consultez les Conditions d'utilisation.