OPEN-SOURCE SCRIPT
Automatic Wedge & Channel Detector

https://www.tradingview.com/x/fCoZjNsv/
Automatic Wedge & Channel Detector identifies developing price structures directly on the chart, helping traders recognize where price is compressing, expanding, or moving within established boundaries.
Instead of requiring trendlines to be drawn manually, the indicator analyzes confirmed pivot highs and lows, tests multiple boundary combinations, and selects the structure that best fits recent price action. It can detect parallel channels, converging wedges, symmetrical triangles, ascending or descending triangle-style formations, and expanding structures.
The goal is not simply to draw two lines. The indicator evaluates how well price respects both boundaries by considering touches, spacing, violations, structural width, balance between the upper and lower sides, and the age of the pattern. This helps reduce arbitrary trendlines and prioritize structures that are better supported by actual price behavior.
KEY FEATURES
Automatic Structure Detection
Auto Mode searches recent confirmed pivots and selects the highest-scoring upper and lower boundary combination.
Manual Structure Selection
Manual Mode allows advanced users to choose which historical pivots anchor each boundary.
Multiple Pattern Types
Recognizes parallel channels, converging wedges, symmetrical triangles, ascending and descending triangle/wedge structures, and expanding formations.
Dynamic Support and Resistance Zones
Optional shaded regions highlight the areas near each boundary where price may be more likely to react.
Middle No-Trade Zone
An optional neutral zone identifies the center of the structure, where entries may offer less favorable positioning compared with trades near the boundaries.
Centerline
The midpoint of the structure can be displayed as an additional reference for equilibrium, potential reactions, and profit management.
Confirmed Breakout Detection
A breakout is recognized only after price closes beyond the structure by a configurable ATR-based distance for the required number of confirmation bars. This helps filter minor boundary breaches and wick-only moves.
Breakout Alerts
Alerts are available for confirmed upside and downside structural breaks.
Breakout and Reclaim Logic
If price returns inside the structure for the required number of bars, the previous breakout is treated as reclaimed.
Structure Lifecycle Management
The indicator tracks whether a formation is active, approaching its apex, broken, reclaimed, or expired. Broken structures can remain visible temporarily so traders can review the breakout and watch for possible retests.
Late-Stage Recognition
Converging formations change color when price approaches the apex or when the remaining width becomes unusually narrow. This warns that the structure may be mature and increasingly vulnerable to a breakout.
Volatility-Adjusted Analysis
Touch tolerance, boundary violations, minimum width, breakout distance, and late-stage conditions are measured relative to ATR so the logic can adapt across markets and timeframes.
HOW TO USE IT
For range or mean-reversion setups, traders can watch for reactions near the lower support zone or upper resistance zone while the structure remains active. The center of the formation is marked as a potential no-trade area because entries taken there often have less room to the next boundary and weaker risk-to-reward characteristics.
For breakout setups, traders can wait for a confirmed close beyond a boundary rather than reacting to the first wick through the line. A broken boundary may later become an area of support or resistance during a retest.
Converging wedges and triangles can also be used to identify volatility compression. As the boundaries narrow and price approaches the apex, traders can prepare for expansion without assuming the breakout direction in advance.
AUTO MODE VS. MANUAL MODE
Auto Mode is designed for traders who want the indicator to continuously identify the strongest recent structure.
Manual Mode is intended for traders who prefer greater control over which pivots define the pattern. Pivot #0 represents the most recently confirmed pivot, Pivot #1 is the previous pivot, and so on.
CUSTOM SOURCE
By default, the upper boundary is calculated from pivot highs and the lower boundary from pivot lows. Enabling Use Custom Source applies the selected source to both pivot calculations. This can be useful for traders who prefer structures based on closing prices or another custom data series rather than candle extremes.
IMPORTANT NOTES
Pivot-based detection requires future bars to confirm a swing. Pivot markers are placed on the original pivot bars after confirmation, so structures are not identified at the exact moment the pivot first forms.
In Auto Mode, the selected structure may update when new pivots are confirmed or when a different combination earns a better score. This is expected behavior for a continuously adapting market-structure tool.
Wedges and channels provide context—not certainty. A boundary touch does not guarantee a reversal, and a confirmed break does not guarantee continuation. Traders should combine the indicator with their own trend analysis, price-action confirmation, volume analysis, risk management, and broader market context.
Automatic Wedge & Channel Detector is designed to make complex chart structure easier to see while preserving the discretion required to trade it intelligently.
Automatic Wedge & Channel Detector identifies developing price structures directly on the chart, helping traders recognize where price is compressing, expanding, or moving within established boundaries.
Instead of requiring trendlines to be drawn manually, the indicator analyzes confirmed pivot highs and lows, tests multiple boundary combinations, and selects the structure that best fits recent price action. It can detect parallel channels, converging wedges, symmetrical triangles, ascending or descending triangle-style formations, and expanding structures.
The goal is not simply to draw two lines. The indicator evaluates how well price respects both boundaries by considering touches, spacing, violations, structural width, balance between the upper and lower sides, and the age of the pattern. This helps reduce arbitrary trendlines and prioritize structures that are better supported by actual price behavior.
KEY FEATURES
Automatic Structure Detection
Auto Mode searches recent confirmed pivots and selects the highest-scoring upper and lower boundary combination.
Manual Structure Selection
Manual Mode allows advanced users to choose which historical pivots anchor each boundary.
Multiple Pattern Types
Recognizes parallel channels, converging wedges, symmetrical triangles, ascending and descending triangle/wedge structures, and expanding formations.
Dynamic Support and Resistance Zones
Optional shaded regions highlight the areas near each boundary where price may be more likely to react.
Middle No-Trade Zone
An optional neutral zone identifies the center of the structure, where entries may offer less favorable positioning compared with trades near the boundaries.
Centerline
The midpoint of the structure can be displayed as an additional reference for equilibrium, potential reactions, and profit management.
Confirmed Breakout Detection
A breakout is recognized only after price closes beyond the structure by a configurable ATR-based distance for the required number of confirmation bars. This helps filter minor boundary breaches and wick-only moves.
Breakout Alerts
Alerts are available for confirmed upside and downside structural breaks.
Breakout and Reclaim Logic
If price returns inside the structure for the required number of bars, the previous breakout is treated as reclaimed.
Structure Lifecycle Management
The indicator tracks whether a formation is active, approaching its apex, broken, reclaimed, or expired. Broken structures can remain visible temporarily so traders can review the breakout and watch for possible retests.
Late-Stage Recognition
Converging formations change color when price approaches the apex or when the remaining width becomes unusually narrow. This warns that the structure may be mature and increasingly vulnerable to a breakout.
Volatility-Adjusted Analysis
Touch tolerance, boundary violations, minimum width, breakout distance, and late-stage conditions are measured relative to ATR so the logic can adapt across markets and timeframes.
HOW TO USE IT
For range or mean-reversion setups, traders can watch for reactions near the lower support zone or upper resistance zone while the structure remains active. The center of the formation is marked as a potential no-trade area because entries taken there often have less room to the next boundary and weaker risk-to-reward characteristics.
For breakout setups, traders can wait for a confirmed close beyond a boundary rather than reacting to the first wick through the line. A broken boundary may later become an area of support or resistance during a retest.
Converging wedges and triangles can also be used to identify volatility compression. As the boundaries narrow and price approaches the apex, traders can prepare for expansion without assuming the breakout direction in advance.
AUTO MODE VS. MANUAL MODE
Auto Mode is designed for traders who want the indicator to continuously identify the strongest recent structure.
Manual Mode is intended for traders who prefer greater control over which pivots define the pattern. Pivot #0 represents the most recently confirmed pivot, Pivot #1 is the previous pivot, and so on.
CUSTOM SOURCE
By default, the upper boundary is calculated from pivot highs and the lower boundary from pivot lows. Enabling Use Custom Source applies the selected source to both pivot calculations. This can be useful for traders who prefer structures based on closing prices or another custom data series rather than candle extremes.
IMPORTANT NOTES
Pivot-based detection requires future bars to confirm a swing. Pivot markers are placed on the original pivot bars after confirmation, so structures are not identified at the exact moment the pivot first forms.
In Auto Mode, the selected structure may update when new pivots are confirmed or when a different combination earns a better score. This is expected behavior for a continuously adapting market-structure tool.
Wedges and channels provide context—not certainty. A boundary touch does not guarantee a reversal, and a confirmed break does not guarantee continuation. Traders should combine the indicator with their own trend analysis, price-action confirmation, volume analysis, risk management, and broader market context.
Automatic Wedge & Channel Detector is designed to make complex chart structure easier to see while preserving the discretion required to trade it intelligently.
Skrip sumber terbuka
Dalam semangat TradingView sebenar, pencipta skrip ini telah menjadikannya sumber terbuka, jadi pedagang boleh menilai dan mengesahkan kefungsiannya. Terima kasih kepada penulis! Walaupuan anda boleh menggunakan secara percuma, ingat bahawa penerbitan semula kod ini tertakluk kepada Peraturan Dalaman.
Penafian
Maklumat dan penerbitan adalah tidak bertujuan, dan tidak membentuk, nasihat atau cadangan kewangan, pelaburan, dagangan atau jenis lain yang diberikan atau disahkan oleh TradingView. Baca lebih dalam Terma Penggunaan.
Skrip sumber terbuka
Dalam semangat TradingView sebenar, pencipta skrip ini telah menjadikannya sumber terbuka, jadi pedagang boleh menilai dan mengesahkan kefungsiannya. Terima kasih kepada penulis! Walaupuan anda boleh menggunakan secara percuma, ingat bahawa penerbitan semula kod ini tertakluk kepada Peraturan Dalaman.
Penafian
Maklumat dan penerbitan adalah tidak bertujuan, dan tidak membentuk, nasihat atau cadangan kewangan, pelaburan, dagangan atau jenis lain yang diberikan atau disahkan oleh TradingView. Baca lebih dalam Terma Penggunaan.