OPEN-SOURCE SCRIPT
Cập nhật

Donchian Retest Readiness [AGPro Series]

791
# Donchian Retest Readiness [AGPro Series]

🧠 Core Idea

After price breaks a Donchian Channel boundary, is the broken edge ready to act as a clean retest and continuation reference?


📌 Overview / What it does

Donchian Retest Readiness is a breakout-boundary decision-support script built around Donchian Channels.

The script maps the rolling Donchian high, low, and midpoint, detects channel breaks, builds a retest pocket around the broken edge, scores retest quality from 0 to 100, and projects continuation lanes with target rails.

It does not predict price direction, automate trades, or provide guaranteed signals. It organizes Donchian break context, retest quality, channel edge, risk, and action state into a clean visual workflow.


🎯 Purpose & Design Philosophy

Many breakout tools mark the moment price leaves a range, but the difficult part often comes after the break: deciding whether the broken edge is being respected.

This script was built for traders who want to evaluate Donchian breakout retests without treating every new high or new low as a complete trading idea.

The design supports structured observation: break first, retest pocket second, hold quality third.


⚡ Why This Script Is Different

Most Donchian tools focus on channel highs and lows.

This script does NOT stop at drawing the Donchian Channel.

Instead, it converts the broken channel edge into a decision zone, evaluates whether price returns to that area, measures hold quality, and summarizes readiness with a clear 0-100 score.


⚙️ Methodology

1. Donchian Channel Mapping
2. Breakout Boundary Detection
3. Retest Pocket Construction
4. Hold / Failure Evaluation
5. 0-100 Retest Readiness Score
6. Panel And Alert Output


🗺️ How to Read the Chart

The Donchian Channel shows the rolling high, low, and midpoint.

The retest pocket appears around the broken channel edge after a breakout.

READY RETEST labels appear when price interacts with the broken edge and holds with enough quality.

Continuation lanes and target rails show the projected area beyond the accepted retest context.

The panel summarizes Break State, Retest Score, Channel Edge, Risk, and Action.


🚦 Signals & States

• READY → A qualified Donchian retest has formed.

• MONITOR → A Donchian break is active and retest behavior is being evaluated.

• WAIT → The channel is valid, but no active break / retest context is present.

• INVALIDATED → Price failed back through the broken channel edge.

• BLOCKED → The Donchian channel is not suitable for evaluation under current settings.


🔔 Alerts Logic

Bullish Donchian Retest Ready triggers when price breaks above the Donchian high, returns to the broken edge, and holds with enough score quality.

Bearish Donchian Retest Ready triggers when price breaks below the Donchian low, returns to the broken edge, and holds with enough score quality.

Donchian Break Watch alerts mark the first boundary break when enabled.

Donchian Retest Invalidated triggers when price fails back through the broken edge.

Alerts are attention markers, not trade instructions.


🧩 Confluence Logic

The retest score combines wick response, close pressure beyond the broken edge, proximity to the retest pocket, breakout impulse, relative volume, and channel width quality.

When several of these conditions align, the retest context becomes stronger.


📊 When to Use

• Breakout markets

• Trend continuation setups

• Pullbacks after new highs or new lows

• Donchian Channel structure analysis

• Intraday or swing contexts where retest behavior matters


⚠️ When NOT to Use

• Very low-liquidity symbols

• Extremely noisy chop

• Abnormal spread conditions

• News spikes where retest behavior is unstable

• Markets where every boundary break immediately reverses


🎛️ Key Inputs

• Donchian Length → controls the rolling channel high and low.

• ATR Length → controls retest pocket depth, buffers, targets, and label spacing.

• Minimum Channel Width → blocks weak channels that are too narrow.

• Retest Pocket ATR → controls how wide the broken-edge retest pocket is.

• Minimum Ready Score → controls how selective READY states are.

• Projection Bars → controls how far pockets and targets extend.

• Visual settings → control channel, fill, pocket, lane, labels, tags, and panel.


🖥️ Interface & Visual Design

The script uses a clean AG Pro panel to summarize the current Donchian context.

The visual hierarchy is designed to keep the channel visible while making the active retest pocket and READY label easy to see.

Default settings keep failed and early watch labels off so publication screenshots remain clean.


🧪 Practical Usage Workflow

1. Read the panel state.
2. Check the Donchian channel boundary.
3. Wait for a break and retest pocket.
4. Evaluate whether price holds the broken edge.
5. Review target rails and failure risk.


🔍 Interpretation Guidelines

A READY retest means the broken Donchian edge is being respected according to the script rules.

It does not mean price must continue.

An invalidated retest means price failed back through the broken edge and the breakout context lost quality.


🚫 What This Script Is NOT

This script is not a prediction engine.

It is not a buy or sell signal generator.

It is not an automated trading system.

It does not guarantee breakouts, continuation, or reversals.


⚠️ Limitations & Transparency

Donchian behavior can vary by symbol, timeframe, volatility, and liquidity.

Shorter timeframes may produce more noise.

Longer Donchian lengths may react more slowly.

The script should be interpreted within broader structure, market regime, and risk context.


🧠 Market Context Notes

Donchian edges often become meaningful when market participants react to new highs, new lows, and breakout continuation attempts.

The strongest contexts usually combine a clean boundary break, controlled retest, and enough continuation room.


🧾 Use Case Examples

When price breaks above the Donchian high and later retests the broken edge without closing back through it, the script may mark a bullish READY RETEST.

When price breaks below the Donchian low and retests the edge from below with enough quality, the script may mark a bearish READY RETEST.

When price breaks out and then closes back through the broken edge, the retest can become invalidated.


🧱 System Philosophy

This script follows the AGPro Series approach: structured context, practical scoring, clean visuals, and decision-support states instead of noisy prediction claims.


🔐 Non-Promise Statement

No script can provide certainty.

No output should be treated as guaranteed.

All states are rule-based analytical markers.


📉 Risk Disclosure

Trading involves risk.

Users are responsible for their own decisions, risk management, and position sizing.

This script is for educational and analytical purposes only and does not provide financial advice.


📚 Educational Note

The purpose of this script is to help users study Donchian Channel breakout and retest behavior through a structured visual framework.
Phát hành các Ghi chú
🔧 UPDATE NOTES - V1.1

This update focuses on visual hierarchy, retest-pocket readability, panel standards, and Pine compile safety.

The core purpose of the script remains unchanged.
This release improves how the existing Donchian break, retest, risk, and target context is presented 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
------------------------

• Rebuilt the active retest pocket presentation
The broken Donchian edge now has a cleaner framed pocket with a centered quality badge.

• Improved continuation-lane structure
The projected lane from the broken edge toward the first target is visually separated from the retest pocket.

• Refined right-side tags
Break edge, T1, and T2 tags now update in place instead of being repeatedly deleted and recreated.

• Improved panel layout
The panel now includes retest state and risk / room context while keeping the merged blue AG Pro header row.

• Added stronger compile safety
Helper functions now use explicit parameter types for label, line, and panel alignment handling.


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

• Added a centered retest-pocket badge for cleaner zone interpretation

• Improved pocket border strength and lane transparency for better first-glance readability

• Preserved the Donchian channel lines and subtle channel fill from the published visual style

• Reduced unnecessary tag recreation while keeping the chart visually active

• Kept event labels readable and positioned away from candles


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

• Added Show Pocket Badge control

• Added Right Tag Offset control

• Kept Donchian channel, retest pocket, continuation lane, target rail, event label, and bar-color controls

• Kept panel location, panel theme, panel font size, and label font size configurable

• Kept the panel header in the AGPro Series merged blue-row standard


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

This update does not change the core analytical purpose of the script.

The goal is to improve readability, usability, and chart presentation, not to introduce predictive behavior.

Users should interpret outputs the same way as before, with improved retest-pocket structure and clearer panel context.


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

The script remains a rule-based analytical tool.

Market conditions such as volatility, liquidity, timeframe differences, and Donchian channel width may affect how retest readiness appears.

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.
Phát hành các Ghi chú
🔧 UPDATE NOTES - 1.2

This update adds a live proof statistic and sharpens label contrast in the
Donchian Retest Readiness engine. The Donchian break detection, retest scoring,
risk and target logic remain unchanged. This script continues to function as an
analytical decision tool. It does not predict price direction or provide
guaranteed outcomes.

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

- Retest Win Rate (Proof Layer)
The panel now tracks how often a ready Donchian retest reaches a balanced
one-risk target before failing back through the broken edge. Wins and losses are
counted on confirmed bars only, and samples that resolve neither inside the proof
window are left unresolved and uncounted, so the statistic stays honest and does
not repaint.

- Sharper Label Contrast
The luminance threshold that picks dark or light text for badges, tags, labels
and the action cell was tuned so indigo elements (such as the T2 target tag) now
use dark text and stay clearly readable.

- Safer ATR Normalization
ATR is now guarded against early-bar gaps so channel width, buffers, pockets and
targets stay defined from the first valid bars.

- New Proof Window Setting
A Retest Proof Window input controls how many bars a ready retest has to resolve
before its sample is left uncounted.

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

- Improved readability of target tags and the retest pocket badge
- Kept the Donchian channel, pocket, lane and target rails intact
- Preserved the clean default visual density
- No added chart clutter

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

- Added a Retest Win Rate row to the dashboard panel
- Kept the existing Break State, Retest Score, Channel Edge, Retest State,
Risk / Room and Action rows
- Preserved all existing settings and defaults as backward compatible
- Enhanced overall experience without changing the core engine

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

This update does not change how Donchian breaks are detected or how retest
quality is scored. The Retest Win Rate is a descriptive, backward-looking
statistic of past ready retests, not a forward prediction. Outputs should be
interpreted the same way as before.

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

The script remains a rule-based analytical tool. Volatility, liquidity and
timeframe differences can affect how breaks, retests and statistics appear.
Always interpret outputs 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.

Thông báo miễn trừ trách nhiệm

Thông tin và các ấn phẩm này không nhằm mục đích, và không cấu thành, lời khuyên hoặc khuyến nghị về tài chính, đầu tư, giao dịch hay các loại khác do TradingView cung cấp hoặc xác nhận. Đọc thêm tại Điều khoản Sử dụng.