OPEN-SOURCE SCRIPT
Diupdate

Mitigation Block Quality [AGPro Series]

9 313
OVERVIEW

Mitigation Block Quality grades every order-block retest as A, B, or C based on
the strength, speed, and follow-through of the bounce after price returns to
the block. Instead of just drawing order blocks and leaving you to guess
which ones matter, the script measures each mitigation objectively and keeps
a live scoreboard of how those reactions have been performing.

The result is an order block tool that tells you two things at once: where
the zones are, and how well price has historically respected them on the
symbol and timeframe you are looking at.


UNIQUE EDGE

Most order-block indicators end at detection. This one begins there. Each
time a block is mitigated, the script measures the reaction over a fixed
window and grades the bounce by its ATR-normalized magnitude. That grade
is then reflected everywhere: on the block border, in the on-chart label,
in the dashboard, and in the historical success-rate statistics.

You also get multi-timeframe context, confluence detection, streak tracking,
and a dynamic setup banner that describes the current price-block
relationship in plain English.


METHODOLOGY

1. Detection. Swing pivots are identified using a configurable pivot length.
The last opposite-colored candle before the pivot forms the order block.
2. Mitigation. A block is mitigated when price re-enters the zone.
3. Grading. After a fixed reaction window, the script measures the peak of
the bounce and normalizes it to ATR. Grade A is a strong bounce, B is
solid, C is weak.
4. Invalidation. A body close beyond the block marks it as invalidated.
Invalidated blocks can be hidden or shown as a dotted reference.
5. Retirement. Blocks retire by age, by distance from price, or when the
per-side cap is exceeded.


FEATURES

- A, B, or C grade assigned to every mitigation (ATR-normalized reaction)
- Reaction trail line on Grade A mitigations showing the bounce extent
- Entry marker (diamond) at the exact mitigation bar of Grade A bounces
- Confluence glow when two or more blocks overlap within 0.5 ATR
- Time-based opacity decay so older blocks recede and fresh ones pop
- Optional pulse animation on A/B blocks while price is inside them
- Price-scale labels tagging each active block's grade and side
- Higher-timeframe alignment check against a configurable HTF structural bias
- Dashboard panel with: active count, tested count, success (current),
nearest-block state (Inside / Touching / distance in ATR), all-time
success rate with stacked distribution bar, last-20 success, health
progress bar, current Win/Loss streak, HTF alignment, and a dynamic
setup banner


SIGNALS & ALERTS

Three alert conditions are provided:
- Grade A Mitigation — a premium-quality bounce has been detected
- Grade B Mitigation — a solid bounce has been detected
- Block Invalidation — an active block has been broken

These are alertconditions and can be configured from the TradingView
Create Alert dialog in the usual way.


KEY INPUTS

- Pivot Length and Lookback: control how blocks are detected and how long
they stay on the chart
- Reaction Window and Grade Thresholds (A, B in ATR units): define what
counts as a premium, solid, or weak bounce
- Invalidation Mode: choose between body close or wick pierce
- Retire Block Beyond (xATR): automatic cleanup when price moves far away
- Max Active Blocks per Side and Max Visible Labels: keep the chart premium
- Premium Visuals toggles: Reaction Trail, Entry Marker, Confluence Glow,
Quality Heatmap row, Setup Banner, Pulse, Time Decay, Price Scale Labels,
HTF Alignment, Streak row
- HTF for Alignment: the higher timeframe used for multi-timeframe confluence
- Panel location and theme


HOW TO USE

1. Add the script to any chart and timeframe.
2. Read the panel top-down:
- Last 20 breakdown tells you the recent quality regime
- Nearest Block tells you how close the closest active zone is
- All-time and Last 20 success tell you how reliable those zones have been
- Streak gives you momentum context
- HTF Alignment tells you if the bigger picture agrees
- Setup banner describes what is happening right now
3. Look at the chart:
- A/B/C labels on mitigated blocks tell you how those tests resolved
- Reaction trails and diamonds highlight the premium Grade A mitigations
- Confluence glows mark zones where multiple blocks agree
4. Use alerts to get notified when a fresh Grade A or Grade B mitigation
occurs, or when an active block is invalidated.

The tool is designed to help with discretionary analysis. It is not a
trading system and does not generate buy or sell signals on its own.


LIMITATIONS & TRANSPARENCY

- Pivots are confirmed after the swing length completes, so block detection
has a small structural lag. This is inherent to any pivot-based method.
- Grades are assigned after the reaction window closes. A very fresh
mitigation will briefly show "Active" before its grade appears.
- HTF Alignment uses a 50-period simple moving average on the chosen higher
timeframe as a structural bias proxy. It is a context filter, not a
predictive signal.
- All metrics are computed from the visible historical data on the current
chart. Loading more bars will change the all-time statistics.
- The script uses Pine Script v6 drawing objects. Extremely long histories
on very low timeframes may hit TradingView object limits; the built-in
per-side cap and distance-based retire keep this under control in normal
use.


RISK DISCLOSURE

This script is an analysis aid, not financial advice. It does not predict
future price movement and does not generate trade recommendations. Any
decision to enter or exit a position is the responsibility of the user.
Historical grade distributions are descriptive, not predictive. Past
mitigation behavior on a symbol does not guarantee future behavior.
Trade with risk capital you can afford to lose and use appropriate
position sizing and stop placement.


LICENSE

Released under the Mozilla Public License 2.0. The full source is available
on TradingView via the Open-Source badge. You are free to study and modify
the code subject to the terms of the license.
Catatan Rilis
🔧 UPDATE NOTES - V2.2

This update focuses on mitigation lifecycle clarity, planner-style scoring, chart readability, and decision-state usability.

The core purpose of the script remains unchanged.
This release improves how the existing mitigation-block logic is presented, organized, and interpreted on the chart.

This script continues to function as an analytical and visualization tool.
It does not attempt to predict price direction or provide guaranteed outcomes.


------------------------
What Changed
------------------------

• Added a mitigation lifecycle layer
The script now classifies the nearest active mitigation block as partial, full, clean, defended, weak, or invalidated.

• Added 0-100 Block Quality scoring
The score combines mitigation depth, reaction strength, block width, hit count, and time decay into a cleaner planner-style quality reading.

• Added defense rail logic
Each active block can now show a clear defense rail at the invalidation edge, helping users separate defended mitigation from weakening structure.

• Reworked the panel into a decision panel
The panel now prioritizes Mitigation State, Block Quality, Defense, Invalidation, and Action instead of only historical success statistics.

• Expanded alerts
New alert logic covers READY state, confirmed lifecycle state shifts, major follow-through, and invalidation events.


------------------------
Visual Improvements
------------------------

• Added centered lifecycle text inside visible mitigation blocks.

• Improved chart readability by separating defense rails from mid-level reference lines.

• Kept labels offset to the right side of the chart so they do not get buried inside candles.

• Preserved controlled label density through max-visible label and object limits.

• Maintained the AGPro blue merged panel header standard.


------------------------
Interface & Usability
------------------------

• Added Sensitivity, Confirmation Mode, Minimum Quality Score, Event Cooldown Bars, and Max Visible Objects controls.

• Preserved panel location, panel theme, panel font size, and label font size settings.

• Kept the panel visible by default while retaining the show/hide setting.

• Added clearer professional tooltips for the new planner controls.


------------------------
Behavior Notes
------------------------

This update does not turn the script into a generic order block scanner or a breaker block engine.

The goal is to clarify the mitigation lifecycle: whether price is only testing the block, defending it, weakening it, or invalidating it.

Users should interpret outputs as structured context, not as standalone trade instructions.


------------------------
Limitations Reminder
------------------------

The script remains a rule-based analytical tool.

Market conditions such as volatility, liquidity, and timeframe differences may affect how mitigation states appear.

Pivot-based block detection and reaction-window grading naturally include confirmation delay.


------------------------
Risk Reminder
------------------------

This script is for educational and analytical purposes only.

It does not provide financial advice or guaranteed trading outcomes.

Users remain responsible for their own decisions.
Catatan Rilis
UPDATE NOTES - VERSION 2.9

This update centers each right-edge zone label on its zone, for a cleaner read.

The core purpose of the script remains unchanged. Mitigation detection, the 0-100 block
quality score, the A / B / C grading, the lifecycle states, the defense rail, invalidation
distance, the reaction trail, touch markers, confluence glow, time decay, higher-timeframe
alignment, the win/loss streak, the A/B resolution ratio, and the next-action state all
behave exactly as before.

This script continues to function as an analytical and visualization tool. It does not
attempt to predict price direction or provide guaranteed outcomes.


------------------------
What Changed
------------------------

• Right-edge labels centered on the zone
The detailed right-edge label is now aligned to the vertical middle of its zone instead of
the zone edge. It sits level with the zone's dotted mid-line, so the label clearly belongs
to that zone at a glance.

• Natural separation
Because stacked zones sit at different mid-prices, their labels now spread apart on their
own. The existing spacing pass remains as a safety net for zones whose mid-prices are very
close, so labels still never overlap.


------------------------
Visual Improvements
------------------------

• Each right-edge label lines up with the middle of its zone and its mid-line.

• Stacked zones read more clearly because their labels separate by zone center.

• Reliable spacing keeps labels from overlapping in busy clusters.

• Kept the centered in-zone badge on live zones and the full panel intact.

• Maintained the clean, premium chart presentation.


------------------------
Interface & Usability
------------------------

• The link between a label and its zone is now obvious at a glance.

• No new settings; existing toggles continue to behave as before.

• Default visual behaviour is improved without requiring any configuration.

• Enhanced readability without changing the core logic.


------------------------
Behavior Notes
------------------------

This update does not change the core analytical logic of the script. Detection, scoring,
grading, lifecycle states, the defense rail, invalidation, and every panel metric are
identical to the previous version.

The change is presentational: the right-edge label now anchors at the zone mid rather than
the zone edge. Everything else reads exactly as before.

Users should interpret all outputs exactly as before.


------------------------
Limitations Reminder
------------------------

The script remains a rule-based analytical tool.

Mitigation grading and quality reflect only the history visible on the current chart and
are affected by symbol, timeframe, volatility, and liquidity.

Outputs should always be interpreted within broader market context.


------------------------
Risk Reminder
------------------------

This script is for educational and analytical purposes only.

It does not provide financial advice or guaranteed trading outcomes.

Users remain responsible for their own decisions.

Pernyataan Penyangkalan

Informasi dan publikasi ini tidak dimaksudkan, dan bukan merupakan, saran atau rekomendasi keuangan, investasi, trading, atau jenis lainnya yang diberikan atau didukung oleh TradingView. Baca selengkapnya di Ketentuan Penggunaan.