OPEN-SOURCE SCRIPT
ที่อัปเดต:

Trendline Retest Planner [AGPro Series]

7 062
Trendline Retest Planner [AGPro Series]

🧠 Core Idea

Is the active trendline retest constructive enough to keep the setup under review, or is it starting to fail?


📌 Overview / What it does

Trendline Retest Planner [AGPro Series] is a chart-first decision tool for traders who review price behavior around active support and resistance trendline retests.

Instead of drawing many trendlines or flagging every break, the script focuses on one active trendline retest context at a time. It measures line age, touch count, retest depth, close response, and volume support, then converts that evidence into a 0-100 Retest Score and a clear next-action state.

The script produces an active trendline, retest pocket, hold/fail labels, invalidation edge, target path, alerts, and a compact AGPro planning panel. It does not predict price movement, automate execution, or provide guaranteed outcomes.


🎯 Purpose & Design Philosophy

This script was built to fill the gap between auto-trendline drawing and practical retest planning.

Many tools can draw diagonals or detect a break. The harder question is what to do after price returns to the line: is the retest holding, weakening, failing, or still waiting for confirmation?

Trendline Retest Planner supports a decision workflow: identify the active retest, read the score, locate the invalidation edge, compare the target path, and decide what deserves review next.


⚡ Why This Script Is Different

Most trendline tools focus on drawing many lines, ranking confluence, or detecting trendline breaks.

This script does NOT clone Auto Trendline Break Quality, Auto Trendlines MTF - Break/Retest, Trendline Confluence Map, Break-Retest Quality, Structure Retest Planner, Swing Retest Quality, or a generic support/resistance zone map.

Instead, it narrows the workflow to one active support or resistance trendline retest and evaluates whether that retest is constructive or failing. The main output is not a buy or sell signal. It is a decision state: READY, MONITOR, FAILING, INVALIDATED, WATCH, WAIT, or SCAN.


⚙️ Methodology

1. Context Detection
The script builds the latest support and resistance trendline candidates from confirmed swing pivots, then selects the nearest valid retest context.

2. Reference Mapping
It maps the active trendline, a retest pocket around the line, an invalidation edge, and a forward target path.

3. Reaction Evaluation
The 0-100 model scores line age, touch count, retest depth, close response, and volume support.

4. Visual Output
The chart shows the active planning objects, compact state labels, and a clean AGPro decision panel.


🗺️ How to Read the Chart

Trendline = the active support or resistance line being evaluated.

Retest Pocket = the ATR-based area around the trendline where a retest is considered active.

Invalidation Edge = the planning reference where the active retest context is considered broken.

Target Path = a forward guide based on the trendline-to-risk distance.

Labels = compact TEST, READY, MONITOR, WEAK, INVALID, PATH, and sparse context labels.

Colors = teal marks support-side retest context, pink marks resistance-side retest context, amber marks caution, indigo marks monitoring/follow-through, and red marks invalidation.

Panel = the AGPro panel summarizes Trendline Side, Retest Score, Hold State, Risk Edge, and Action.


🚦 Signals & States

• READY → the retest is active, holding on the correct side, and the score is strong enough for structured review.

• MONITOR → the retest is developing, but confirmation or score quality is still incomplete.

• FAILING → price touched the pocket, but the response is weak or on the wrong side.

• INVALIDATED → price crossed the invalidation edge and the active context should be rebuilt.

• WATCH → price is approaching the trendline pocket.

• WAIT → a valid trendline exists, but price is not close enough for useful retest review.

• SCAN → no valid trendline context is active yet.


🔔 Alerts Logic

Alerts trigger when price touches the active retest pocket, when READY state appears, when MONITOR state appears, when a failing retest is detected, when the invalidation edge is crossed, and when follow-through appears after an active retest.

Alerts are attention markers only. They are not trade instructions, automated strategy commands, or outcome promises.


🧩 Confluence Logic

The strongest context appears when the active line is fresh enough, has enough touches, retests with controlled depth, closes back on the correct side, and receives supportive relative volume.

When these components conflict, the panel moves toward MONITOR, FAILING, WATCH, WAIT, or INVALIDATED.


📊 When to Use

• Trendline support retests during constructive pullbacks

• Trendline resistance retests during bearish continuation attempts

• Price-action review after a diagonal support or resistance line is already visible

• Retest planning where invalidation and target path matter

• Liquid markets where pivots, candles, and volume behavior are readable


⚠️ When NOT to Use

• Very low-liquidity symbols with irregular candles

• Extremely noisy micro-timeframes

• News-driven spikes where trendline geometry becomes distorted

• Markets where swing pivots are too compressed to form useful lines

• Situations where the user expects a signal-only or auto-trading tool


🎛️ Key Inputs

• Trendline Side → selects Auto, Support Retest, or Resistance Retest.

• Trendline Pivot Length → controls how confirmed swing anchors are detected.

• Max Trendline Age → controls how old a trendline can be before it is ignored.

• Touch Count Lookback → controls how extra line touches are counted.

• Sensitivity → adjusts retest pocket width and activation distance.

• READY Score → sets the score threshold for stronger review states.

• Label and Panel Font Size → controls chart-label and panel readability.

• Panel Location and Theme → adjusts the AGPro panel layout.


🖥️ Interface & Visual Design

The interface is designed to stay chart-first and decision-led.

The active trendline is the main reference. The retest pocket is drawn around that line with centered text so the chart stays readable. The invalidation edge and target path explain where the planning context weakens and what forward room is being mapped.

The AGPro panel uses a merged blue title row and five compact rows so the user can read side, score, hold state, risk edge, and action quickly.


🧪 Practical Usage Workflow

1. Read the panel state and Retest Score.

2. Check whether price is approaching or touching the retest pocket.

3. Compare current price with the invalidation edge.

4. Review whether the label says TEST, READY, MONITOR, WEAK, INVALID, or PATH.

5. Confirm the broader market context before making any decision.


🔍 Interpretation Guidelines

Think in terms of retest quality, not prediction.

A higher score means multiple retest components align inside the script's rule set. A weaker score means the line may be too old, the retest may be too shallow, too deep, missing a constructive close, or lacking participation.

The script helps organize the review process. It does not replace judgment.


🚫 What This Script Is NOT

• Not a prediction engine

• Not financial advice

• Not an auto-trading system

• Not a guaranteed signal tool

• Not a broad auto-trendline map

• Not a trendline confluence scanner

• Not a break-and-retest scanner

• Not a generic support/resistance zone map

• Not an order block, FVG, or supply/demand tool


⚠️ Limitations & Transparency

• Pivot-based trendlines appear only after pivots are confirmed.

• Scores can vary across symbols, sessions, and timeframes.

• Volume scoring depends on exchange-provided volume data.

• Fast volatility can cross a trendline before a clean retest can be measured.

• In Live Updating mode, active-bar values can change before the bar closes.


🧠 Market Context Notes

Trendline retests are easiest to interpret when liquidity, volatility, and swing structure are readable.

A trendline touch is not enough by itself. Line quality, response, invalidation distance, and target path all matter.


🧾 Use Case Examples

When price returns to an upward support trendline and closes back above the pocket with a high score, the panel may move toward READY.

When price touches a downward resistance trendline but cannot close back below it, the planner may move toward FAILING or INVALIDATED.

When price is near the line but has not touched the pocket yet, the panel can stay in WATCH or WAIT.


🧱 System Philosophy

Trendline Retest Planner follows the AGPro decision-engine approach: identify context, score quality, map risk, show the next action, and keep the chart readable.

It is designed to help traders evaluate a specific planning question instead of adding another generic signal layer.


🔐 Non-Promise Statement

No score, label, alert, or chart object guarantees any market outcome.

The script organizes retest context and highlights conditions for review. It does not provide certainty.


📉 Risk Disclosure

Trading involves risk.

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

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


📚 Educational Note

Use the planner as a structured reading layer: trendline context first, retest quality second, invalidation and target path third, broader market context always.
Release Note
UPDATE NOTES - V1.1

This update focuses on retest-pocket label clarity, chart readability, and AGPro visual consistency.

The core purpose of the script remains unchanged.
This release improves how the existing retest pocket is labeled 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
------------------------

* Reworked the retest pocket label.
The previous retest-zone text was embedded directly inside the box object.

* Added a separate centered badge label.
The pocket now uses an independent AGPro-style label object placed at the horizontal and vertical center of the retest zone.

* Removed box text payload usage.
The retest pocket no longer uses box text fields or box text updates.

* Added state-aware badge styling.
The badge color now reflects invalidated, ready, monitor, failing, and active retest states.


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

* Improved chart readability by making the retest pocket label more visible.

* Refined the visual hierarchy so the pocket label stands out as a premium badge.

* Preserved the clean retest zone while improving the readability of the score label.

* Kept the zone label centered inside the retest pocket.


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

* Preserved the existing panel layout, score model, event labels, and alerts.

* Improved the pocket label without changing how users interpret the planner.

* Enhanced overall user experience without changing core logic.


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

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

The goal is to improve clarity and usability, not to introduce new predictive behavior.

Users should interpret outputs the same way as before, but with improved visual structure.


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

The script remains a rule-based analytical tool.

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

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.
Release Note
🔧 UPDATE NOTES - v1.3

This update focuses on the honesty and readability of the follow-through proof rate.

The core purpose of the script remains unchanged.
This release also includes the v1.2 additions (panel Target row, stop-aware
follow-through Proof row, and unified label contrast) for users updating directly
from v1.1.

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
------------------------

• Follow-through proof is now measured on closes, not wicks
Previously the favorable follow-through side was checked against the bar high or
low while the invalidation side was checked against the close. That asymmetry let
a single wick count as a follow-through and pushed the rate unrealistically high.
Both sides are now evaluated on confirmed closes, so the proof reflects genuine
follow-through rather than intrabar noise.

• Target row added to the panel (from v1.2)
The projected target path level is shown directly in the panel next to the score,
hold state, and risk edge.

• Stop-aware Proof row added (from v1.2)
On each qualified retest (READY or MONITOR), the planner records whether price
followed through off the line before the invalidation edge was closed through, and
reports it as a historical rate with sample count, e.g. "58% (40)".

• Unified label contrast (from v1.2)
All on-chart labels and the centered pocket badge derive text color from fill
brightness so every badge stays legible on both bright and dark fills.


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

• Improved label readability by deriving text color from each badge fill

• Refined panel hierarchy so target and risk edge read as a pair

• Kept label positioning above or below candles unchanged


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

• Panel layout: Side, Score, Hold State, Target, Risk Edge, Action, Proof

• Grouped objective and invalidation for clearer at-a-glance interpretation

• Enhanced overall user experience without changing core retest logic


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

This update does not change the core retest scoring or state logic of the script.

The Proof row is a historical, descriptive follow-through statistic measured on
confirmed closes. It is not a forecast, win rate, or trade instruction, and it is
symbol- and timeframe-dependent. On strongly one-directional symbols the rate
naturally reads lower.

Users should interpret outputs the same way as before, now with a more honest
follow-through statistic and an added target reference.


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

The script remains a rule-based analytical tool.

Market conditions such as volatility, liquidity, and timeframe differences may
affect how retests, the target path, and the proof rate appear.

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.

คำจำกัดสิทธิ์ความรับผิดชอบ

ข้อมูลและบทความไม่ได้มีวัตถุประสงค์เพื่อก่อให้เกิดกิจกรรมทางการเงิน, การลงทุน, การซื้อขาย, ข้อเสนอแนะ หรือคำแนะนำประเภทอื่น ๆ ที่ให้หรือรับรองโดย TradingView อ่านเพิ่มเติมใน ข้อกำหนดการใช้งาน