OPEN-SOURCE SCRIPT
Cập nhật Triangle Breakout Quality [AGPro Series]

Triangle Breakout Quality [AGPro Series]
🔺 OVERVIEW
Triangle Breakout Quality is built for one of the most searched and visually recognizable chart structures in technical analysis: the triangle breakout.
The script automatically detects triangle candidates from confirmed pivot highs and pivot lows, projects the upper and lower converging boundaries, measures how much the structure has compressed, locates the projected apex, and grades the quality of the eventual breakout. After the release, it monitors the first return toward the broken triangle boundary so the user can see whether price accepted the breakout or quickly lost structural quality.
The goal is not to mark every small consolidation or every trendline touch. The goal is to isolate the full triangle sequence:
Formation -> compression -> apex pressure -> boundary release -> first retest state.
That full lifecycle is what gives the tool its own identity. A triangle is not just a range, not just a single diagonal line, and not just a breakout candle. It is a narrowing structure where both sides of price are being compressed into a decision point. This script is designed around that idea from the ground up.
🔹 WHAT MAKES IT DIFFERENT
Most triangle tools stop at drawing two lines. Most breakout tools stop at the first candle outside a boundary. Triangle Breakout Quality does more by turning the structure into a scored, state-aware workflow.
Core differentiators:
• Dual-boundary validation
The script requires both an upper pivot boundary and a lower pivot boundary. The two lines must converge. This prevents the logic from acting like a generic trendline-break detector.
• Compression measurement
The engine compares the opening width of the triangle with the current width. A pattern must show meaningful narrowing before it can qualify.
• Apex pressure logic
The script projects where the upper and lower boundaries intersect and evaluates whether the current structure is close enough to that decision zone to matter.
• Breakout quality score
Every displayed breakout receives a 0-100 score based on compression, apex pressure, breakout distance, candle body participation, close quality, and optional volume expansion.
• Retest state
After a breakout, the script watches the first return toward the broken triangle boundary. A held retest and a failed retest are visually different states, not the same event.
• Premium visual restraint
The chart shows active triangle lines, controlled breakout labels, optional retest labels, subtle candle tint, and a compact AGPro panel. Label density is capped so the layout stays clean for live use and publication screenshots.
🧭 WHY THIS DOES NOT OVERLAP WITH OTHER AGPRO TOOLS
This script is intentionally separated from the existing AGPro breakout and structure family.
It is not Break-Retest Quality, because it does not begin with a horizontal pivot break and then grade the first retest of that static level. Triangle Breakout Quality first requires a valid converging triangle structure.
It is not Failed Break Quality, because it is not centered on false breaks and reclaim behavior. It tracks the primary breakout from a valid triangle and then monitors the first boundary retest.
It is not Consolidation Breakout Quality, because the reference structure is not a horizontal range. A triangle must have two projected pivot boundaries that move toward each other.
It is not Donchian Breakout Quality, because it is not based on period highs and lows or channel escape logic.
It is not ATR Envelope Breakout Quality, because it does not use a volatility envelope as the breakout shell.
It is not Auto Trendline Break Quality, because it does not score isolated trendline breaks. The event only matters when the upper and lower lines together form a valid triangle compression structure.
That distinction matters visually and analytically. On the chart, this script tells a triangle story: converging boundaries, apex pressure, breakout quality, and retest state. It belongs in the chart-pattern lane, not the generic breakout lane.
⚙️ METHODOLOGY
1. Pivot anchors
The script uses confirmed pivot highs and pivot lows to define the latest upper and lower triangle boundaries. This keeps the structure rules transparent and reproducible.
2. Convergence filter
The upper boundary and lower boundary must move toward each other. The current width of the pattern must be smaller than the starting width, and the compression percentage must meet the selected threshold.
3. Width and maturity filters
The pattern must be old enough to represent a real structure, but not so old that it becomes stale. The starting width and current width are also normalized by ATR so the same logic can adapt across symbols and timeframes.
4. Apex projection
The script calculates where the two projected boundaries intersect. This creates the apex pressure layer, which helps separate mature triangle compression from loose diagonal movement.
5. Breakout confirmation
A bullish breakout requires price to close beyond the projected upper boundary by an ATR-normalized buffer. A bearish breakout requires price to close beyond the projected lower boundary by the same type of buffer.
6. Quality score
The breakout score combines:
• Compression quality
• Apex pressure
• Breakout distance beyond the boundary
• Candle body participation
• Close position inside the breakout candle
• Optional volume participation
The result is displayed as a compact grade and score so the chart remains readable.
7. Retest state
After a breakout, the script projects the broken triangle boundary forward internally and evaluates an ATR-scaled retest tolerance around it. If price revisits that boundary area and holds the correct side, the retest is marked as held. If price loses the boundary, the retest state is marked as failed.
📊 PANEL
The AGPro panel summarizes the current structure and latest event:
• Pattern Age
• Compression
• Apex Pressure
• Breakout Side
• Retest Quality
• Current State
Panel location, theme, and font size are adjustable. The first row follows the AGPro publication standard: one merged blue header row containing only the panel title.
🎛️ KEY INPUTS
Triangle Structure
• Pivot Length
• Minimum Pattern Age
• Maximum Pattern Age
• Minimum Compression %
• Minimum Starting Width ATR
• Maximum Current Width ATR
• Maximum Forward Apex Bars
Breakout Quality
• ATR Length
• Volume Average Length
• Use Volume Participation
• Volume Full-Score Ratio
• Minimum Break Distance ATR
• High Quality Threshold
• Minimum Label Score
• Visual Cooldown Bars
Retest State
• Retest Minimum Bars
• Retest Window Bars
• Retest Tolerance ATR
Visual Controls
• Show Triangle Lines
• Show Breakout Labels
• Show Retest Labels
• Tint Breakout Candles
• Label Offset ATR
• Label Font Size
• Maximum Visible Events
Panel
• Show Panel
• Panel Position
• Panel Theme
• Panel Font Size
🔍 HOW TO READ IT
When a valid triangle is forming, the chart displays the converging upper and lower boundaries. The panel reports apex pressure and compression so the projected decision area is visible without adding extra rectangles to the chart. Compression shows how much the pattern has tightened relative to its opening width.
When price closes beyond a valid boundary, the script prints a compact breakout label with a quality grade and score. A higher score means the breakout candle carried stronger structural qualities according to the script's rules.
After the breakout, retest labels and the panel show whether the first return toward the broken triangle boundary held or failed. A held retest suggests cleaner acceptance of the breakout boundary. A failed retest suggests the release lost quality.
Use the tool as a structured chart-reading layer. It is designed to help users compare triangle breakouts by quality, not to replace broader context such as trend, liquidity, session behavior, or personal execution rules.
🧩 BEST USE CASES
• Symmetrical triangle compression
• Ascending triangle pressure
• Descending triangle pressure
• Breakout candle quality review
• First retest monitoring after triangle release
• Screenshot-friendly pattern study
• Multi-symbol scanning for cleaner chart-pattern candidates
🔹 LIMITATIONS AND TRANSPARENCY
Triangle detection is based on confirmed pivots, so the final anchor points appear only after the selected pivot length has elapsed. This is standard pivot behavior and keeps the structure rules visible.
The live triangle can change while new pivots form. Breakout and retest labels are event-based and are designed to remain stable after confirmation.
Volume participation is optional because volume quality varies across markets and feeds. On instruments where volume is less informative, the volume component can be disabled.
The score is a structured description of the triangle release according to the script's internal model. It should be read as context, not as an execution command.
🔺 OVERVIEW
Triangle Breakout Quality is built for one of the most searched and visually recognizable chart structures in technical analysis: the triangle breakout.
The script automatically detects triangle candidates from confirmed pivot highs and pivot lows, projects the upper and lower converging boundaries, measures how much the structure has compressed, locates the projected apex, and grades the quality of the eventual breakout. After the release, it monitors the first return toward the broken triangle boundary so the user can see whether price accepted the breakout or quickly lost structural quality.
The goal is not to mark every small consolidation or every trendline touch. The goal is to isolate the full triangle sequence:
Formation -> compression -> apex pressure -> boundary release -> first retest state.
That full lifecycle is what gives the tool its own identity. A triangle is not just a range, not just a single diagonal line, and not just a breakout candle. It is a narrowing structure where both sides of price are being compressed into a decision point. This script is designed around that idea from the ground up.
🔹 WHAT MAKES IT DIFFERENT
Most triangle tools stop at drawing two lines. Most breakout tools stop at the first candle outside a boundary. Triangle Breakout Quality does more by turning the structure into a scored, state-aware workflow.
Core differentiators:
• Dual-boundary validation
The script requires both an upper pivot boundary and a lower pivot boundary. The two lines must converge. This prevents the logic from acting like a generic trendline-break detector.
• Compression measurement
The engine compares the opening width of the triangle with the current width. A pattern must show meaningful narrowing before it can qualify.
• Apex pressure logic
The script projects where the upper and lower boundaries intersect and evaluates whether the current structure is close enough to that decision zone to matter.
• Breakout quality score
Every displayed breakout receives a 0-100 score based on compression, apex pressure, breakout distance, candle body participation, close quality, and optional volume expansion.
• Retest state
After a breakout, the script watches the first return toward the broken triangle boundary. A held retest and a failed retest are visually different states, not the same event.
• Premium visual restraint
The chart shows active triangle lines, controlled breakout labels, optional retest labels, subtle candle tint, and a compact AGPro panel. Label density is capped so the layout stays clean for live use and publication screenshots.
🧭 WHY THIS DOES NOT OVERLAP WITH OTHER AGPRO TOOLS
This script is intentionally separated from the existing AGPro breakout and structure family.
It is not Break-Retest Quality, because it does not begin with a horizontal pivot break and then grade the first retest of that static level. Triangle Breakout Quality first requires a valid converging triangle structure.
It is not Failed Break Quality, because it is not centered on false breaks and reclaim behavior. It tracks the primary breakout from a valid triangle and then monitors the first boundary retest.
It is not Consolidation Breakout Quality, because the reference structure is not a horizontal range. A triangle must have two projected pivot boundaries that move toward each other.
It is not Donchian Breakout Quality, because it is not based on period highs and lows or channel escape logic.
It is not ATR Envelope Breakout Quality, because it does not use a volatility envelope as the breakout shell.
It is not Auto Trendline Break Quality, because it does not score isolated trendline breaks. The event only matters when the upper and lower lines together form a valid triangle compression structure.
That distinction matters visually and analytically. On the chart, this script tells a triangle story: converging boundaries, apex pressure, breakout quality, and retest state. It belongs in the chart-pattern lane, not the generic breakout lane.
⚙️ METHODOLOGY
1. Pivot anchors
The script uses confirmed pivot highs and pivot lows to define the latest upper and lower triangle boundaries. This keeps the structure rules transparent and reproducible.
2. Convergence filter
The upper boundary and lower boundary must move toward each other. The current width of the pattern must be smaller than the starting width, and the compression percentage must meet the selected threshold.
3. Width and maturity filters
The pattern must be old enough to represent a real structure, but not so old that it becomes stale. The starting width and current width are also normalized by ATR so the same logic can adapt across symbols and timeframes.
4. Apex projection
The script calculates where the two projected boundaries intersect. This creates the apex pressure layer, which helps separate mature triangle compression from loose diagonal movement.
5. Breakout confirmation
A bullish breakout requires price to close beyond the projected upper boundary by an ATR-normalized buffer. A bearish breakout requires price to close beyond the projected lower boundary by the same type of buffer.
6. Quality score
The breakout score combines:
• Compression quality
• Apex pressure
• Breakout distance beyond the boundary
• Candle body participation
• Close position inside the breakout candle
• Optional volume participation
The result is displayed as a compact grade and score so the chart remains readable.
7. Retest state
After a breakout, the script projects the broken triangle boundary forward internally and evaluates an ATR-scaled retest tolerance around it. If price revisits that boundary area and holds the correct side, the retest is marked as held. If price loses the boundary, the retest state is marked as failed.
📊 PANEL
The AGPro panel summarizes the current structure and latest event:
• Pattern Age
• Compression
• Apex Pressure
• Breakout Side
• Retest Quality
• Current State
Panel location, theme, and font size are adjustable. The first row follows the AGPro publication standard: one merged blue header row containing only the panel title.
🎛️ KEY INPUTS
Triangle Structure
• Pivot Length
• Minimum Pattern Age
• Maximum Pattern Age
• Minimum Compression %
• Minimum Starting Width ATR
• Maximum Current Width ATR
• Maximum Forward Apex Bars
Breakout Quality
• ATR Length
• Volume Average Length
• Use Volume Participation
• Volume Full-Score Ratio
• Minimum Break Distance ATR
• High Quality Threshold
• Minimum Label Score
• Visual Cooldown Bars
Retest State
• Retest Minimum Bars
• Retest Window Bars
• Retest Tolerance ATR
Visual Controls
• Show Triangle Lines
• Show Breakout Labels
• Show Retest Labels
• Tint Breakout Candles
• Label Offset ATR
• Label Font Size
• Maximum Visible Events
Panel
• Show Panel
• Panel Position
• Panel Theme
• Panel Font Size
🔍 HOW TO READ IT
When a valid triangle is forming, the chart displays the converging upper and lower boundaries. The panel reports apex pressure and compression so the projected decision area is visible without adding extra rectangles to the chart. Compression shows how much the pattern has tightened relative to its opening width.
When price closes beyond a valid boundary, the script prints a compact breakout label with a quality grade and score. A higher score means the breakout candle carried stronger structural qualities according to the script's rules.
After the breakout, retest labels and the panel show whether the first return toward the broken triangle boundary held or failed. A held retest suggests cleaner acceptance of the breakout boundary. A failed retest suggests the release lost quality.
Use the tool as a structured chart-reading layer. It is designed to help users compare triangle breakouts by quality, not to replace broader context such as trend, liquidity, session behavior, or personal execution rules.
🧩 BEST USE CASES
• Symmetrical triangle compression
• Ascending triangle pressure
• Descending triangle pressure
• Breakout candle quality review
• First retest monitoring after triangle release
• Screenshot-friendly pattern study
• Multi-symbol scanning for cleaner chart-pattern candidates
🔹 LIMITATIONS AND TRANSPARENCY
Triangle detection is based on confirmed pivots, so the final anchor points appear only after the selected pivot length has elapsed. This is standard pivot behavior and keeps the structure rules visible.
The live triangle can change while new pivots form. Breakout and retest labels are event-based and are designed to remain stable after confirmation.
Volume participation is optional because volume quality varies across markets and feeds. On instruments where volume is less informative, the volume component can be disabled.
The score is a structured description of the triangle release according to the script's internal model. It should be read as context, not as an execution command.
Phát hành các Ghi chú
UPDATE NOTES - v1.1This update focuses on readability and visual clarity.
The core purpose of the script remains unchanged. This release improves how the
existing triangle structures, breakout grades and retest states are presented on
the chart. It continues to function as an analytical and visualization tool and
does not attempt to predict price direction or provide guaranteed outcomes.
------------------------
What Changed
------------------------
- Anti-collision label stagger
Breakout and retest labels that land close together now stack progressively
instead of overlapping, so the side, grade and score on each tag stay readable
even when several events cluster within a few bars.
- Faded but visible historical structures
Past triangle structures are now drawn in a softer tone than the active forming
triangle. The active structure uses the accent color and full weight, while
completed structures recede - keeping history visible without competing with the
live pattern.
- Cleaner event density
The default number of historical event packages kept on the chart was reduced,
so charts and screenshots stay uncluttered while still showing recent context.
- Increased label clearance
The default vertical label offset was increased, and retest labels are placed
further from the broken boundary, so tags sit clearly outside the candles
instead of touching them.
------------------------
Visual Improvements
------------------------
- Improved chart readability by separating overlapping breakout and retest tags.
- Reduced visual clutter by softening completed structures and lowering the
default event count.
- Refined visual hierarchy so the active forming triangle stands out from past
breakout structures by both color and weight.
- Adjusted label positioning to avoid overlap with candles.
------------------------
Interface & Usability
------------------------
- Adjusted default visual settings (label offset and maximum visible events) for
a more balanced, cleaner appearance out of the box.
- Improved label readability for clearer chart interaction.
- Enhanced overall first-glance experience without changing the core logic.
------------------------
Behavior Notes
------------------------
This update does not change the core analytical logic of the script. Triangle
detection, the breakout quality score, and the retest state evaluation are
unchanged. Only the presentation of those outputs was refined. Users should
interpret outputs the same way as before, now with clearer visual structure.
------------------------
Limitations Reminder
------------------------
The script remains a rule-based analytical tool. Market conditions such as
volatility, liquidity and timeframe differences may affect how triangles,
breakouts and 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.
Mã nguồn mở
Theo đúng tinh thần TradingView, tác giả của tập lệnh này đã công bố nó dưới dạng mã nguồn mở, để các nhà giao dịch có thể xem xét và xác minh chức năng. Chúc mừng tác giả! Mặc dù bạn có thể sử dụng miễn phí, hãy nhớ rằng việc công bố lại mã phải tuân theo Nội quy.
Public-free and invite-only TradingView Pine Script tools for market analysis, risk planning, liquidity and execution review.
Script library & access: aligurtuna.com/agprolabs-pine-scriptleri/
Telegram: t.me/agprolabs
Script library & access: aligurtuna.com/agprolabs-pine-scriptleri/
Telegram: t.me/agprolabs
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.
Mã nguồn mở
Theo đúng tinh thần TradingView, tác giả của tập lệnh này đã công bố nó dưới dạng mã nguồn mở, để các nhà giao dịch có thể xem xét và xác minh chức năng. Chúc mừng tác giả! Mặc dù bạn có thể sử dụng miễn phí, hãy nhớ rằng việc công bố lại mã phải tuân theo Nội quy.
Public-free and invite-only TradingView Pine Script tools for market analysis, risk planning, liquidity and execution review.
Script library & access: aligurtuna.com/agprolabs-pine-scriptleri/
Telegram: t.me/agprolabs
Script library & access: aligurtuna.com/agprolabs-pine-scriptleri/
Telegram: t.me/agprolabs
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.