OPEN-SOURCE SCRIPT
Telah dikemas kini

Auto Channel Detector

300
Auto Channel Detector finds the highest-quality price channel on the chart automatically and draws it as two parallel lines with a fill.

HOW IT WORKS
The script collects recent confirmed swing highs and swing lows (ta.pivothigh / ta.pivotlow). It then tests every pair of pivot highs against every pair of pivot lows as candidate channel walls and applies three quality gates:
1. Parallelism — the two walls must have nearly identical slopes (tolerance scaled by ATR over the channel span).
2. Minimum width — the channel must be at least 1.5 x ATR(14) wide at its midpoint.
3. Touch count — each wall must be touched by at least 3 bars (a touch = high/low within 0.5 x ATR of the projected line).
The candidate with the most total touches wins and is drawn. If no candidate passes all gates, nothing is drawn.

FALSE-TRIGGER ELIMINATION
- Pivots confirm only after the right-bars lookback, so the channel never repaints.
- Channel selection runs only on confirmed (closed) bars.
- All thresholds are ATR-normalized, so the same settings work across symbols and timeframes.

INPUTS
Pivot left/right bars, max pivots per side, minimum touches, touch band, parallelism tolerance, minimum width, minimum channel length, scan depth, and display options are all configurable.

USAGE
Works on any symbol and timeframe. Use the channel walls as dynamic support/resistance; a confirmed close outside the channel suggests a breakout.
Nota Keluaran
v2 - Fixed stale channel detection.

WHAT WAS WRONG
The touch counter scanned backwards from the current bar, so it counted touches along an old channel's right-extension. A channel from a finished trend could keep winning and float over the chart, far from current price.

WHAT CHANGED
1. Touches are now counted only within the channel's own span (oldest anchor pivot to newest anchor pivot), never along the extension.
2. New "Max Channel Age (bars)" input (default 60): a channel is discarded unless its newest anchor pivot is recent. Stale channels are removed from the chart automatically.

The detector now locks onto the live trend structure instead of a historical one.
Nota Keluaran
v3 - Past channels are now kept on the chart.

Previously only the single live channel was drawn; when it went stale it was deleted, so historical channels vanished. Now, when a channel dies (goes stale or is replaced by a new structure), it is frozen in place as a dimmed, non-extending channel instead of being deleted.

NEW INPUTS (History group)
- Keep Past Channels (default on)
- Max Past Channels (default 8) - oldest frozen channels are removed beyond this cap
- Past Channel Color / Fill - styling for frozen channels

The live channel stays highlighted in the main color; past market structure remains visible in gray.
Nota Keluaran
v4 — Detect ALL channel/structure types, colored by type:

• Now classifies and labels nine structure types: Ascending / Descending Channel, Range, Rising / Falling Wedge, Symmetrical / Ascending / Descending Triangle, and Broadening — not just parallel channels.
• Each type drawn in its own color (channels green/red, range blue, wedges orange, triangles purple, broadening fuchsia).
• A break now CONSUMES the channel: both walls are truncated at the break bar and frozen — the structure never extends past its break.
• Past structures are kept (frozen gray) so you can scroll back through history.
• No-repaint: detection runs only on confirmed bars.
Nota Keluaran
v5 - Cleaner default + per-type channel selection:

- Only the single current channel is shown now. "Show Past Channels" defaults OFF for a clean chart - turn it on to keep past structures frozen in gray as you scroll back.
- New "Channel Types" toggles (Ascending, Descending, Range, Wedges, Triangles, Broadening), all on by default. Since only one channel is drawn, you see only the current channel type; uncheck a type to exclude it and the detector surfaces the next-best channel of a still-enabled type.
- Detection, classification, per-type colors, break-consumes-channel, and no-repaint behavior are unchanged.
Nota Keluaran
v6 - Major performance fix for free accounts:

- The channel search is now event-driven: it runs only when a new swing pivot forms (every ~8-15 bars) instead of on every bar. Same channels, same classification - just no redundant recomputation. Load time drops from ~40s to a few seconds.
- New "Detection Lookback (bars)" input (default 5000): only the most recent N bars are scanned, so deep history is skipped and the script stays within free-account execution-time limits on long charts. Increase for more history, decrease for max speed.
- No change to detection, types, colors, break logic, or no-repaint behavior.
Nota Keluaran
v7 - Accuracy fix: channels no longer consume breakouts/breakdowns.

- A channel is now LOCKED once detected: it is never re-fitted or stretched. Previously the channel re-fit on every new pivot and would quietly widen to swallow a breakout instead of registering it.
- A locked channel ends only on a real break (a close beyond the wall by the Break Buffer), which truncates it at the break bar and fires the BRK signal. A fresh channel is searched for only after the current one breaks.
- Result: genuine breakouts and breakdowns are preserved and shown cleanly instead of being absorbed. No change to types, colors, or no-repaint behavior.

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.