OPEN-SOURCE SCRIPT
Trend Channels Pro [CodedLevels]

Trend Channels Pro [CodedLevels]
A multi-layered trend structure engine that combines regression-based diagonal channels, supply & demand zones, and smart breakout detection into a single unified overlay.
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
🔹 WHAT IT DOES
This indicator builds a complete structural map of the market by layering three analytical systems:
1 — Trend Channels (Essential + Secondary)
Automatically detects swing pivots and fits linear regression channels across each completed trend leg. Channels are rendered as diagonal lines with shaded fills — visually identical to TradingView's built-in Regression Trend drawing tool, but fully automated. Two independent layers work simultaneously:
• Essential Trend — captures dominant market structure using higher-strength pivots. Channels are colored green (bullish legs) or red (bearish legs) based on structural direction.
• Secondary Trend — captures shorter-term structure within the essential trend. Channels are rendered in grey to visually separate them from the primary structure.
Both layers preserve full historical channels on the chart, giving you a complete visual record of how the trend has evolved over time.
2 — Forming Channel (Live)
A real-time channel drawn from the last confirmed pivot to the current bar. It updates on every new candle, showing you the trend leg that is actively developing — before it becomes a confirmed historical channel. Rendered in a distinct color with dashed lines so you can immediately distinguish it from completed channels.
3 — Supply & Demand Zones
Pivot-based zone detection using candle body mapping. Zones are qualified by departure strength — only pivots with meaningful follow-through moves generate zones. Features include:
• Automatic zone merging when nearby zones overlap
• Freshness tracking: fresh (untested) → retested → weakened → invalidated
• Zones auto-remove when price breaks through with conviction
• Centered labels: SUPPLY / DEMAND with freshness indicators
4 — Smart Breakout Signals
Detects when price closes beyond the latest secondary channel boundary. Includes:
• Minimum penetration filter (in ATR multiples) to eliminate marginal breakouts
• Optional volume confirmation
• Trend alignment filter — only signals that agree with the essential trend direction
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
🔹 HOW TREND DIRECTION WORKS
Unlike indicators that determine trend from a moving average or the last candle's slope, this indicator uses structural market analysis:
• Tracks successive pivot highs and pivot lows
• Higher High + Higher Low = Bullish structure
• Lower High + Lower Low = Bearish structure
This means the dashboard won't flip bearish just because price made a normal pullback within an uptrend. It reflects the actual market structure.
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
🔹 HOW TO USE IT
Essential + Secondary channels give you the structural framework — trade in the direction of the essential trend, use secondary channels for timing.
Supply & Demand zones provide confluence — a breakout signal firing near a fresh demand zone in a bullish essential trend is a high-probability setup.
The info table (top-right) shows: essential and secondary trend direction, alignment status (ALIGNED / DIVERGENT), R² values for channel quality, and zone counts.
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
🔹 ALERTS
• Bullish / Bearish breakout (with-trend filtered)
• Any secondary channel break (unfiltered)
• Price entering supply or demand zones
• Confluence alerts: breakout + zone overlap
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
🔹 SETTINGS
All layers can be independently enabled/disabled. Key parameters include swing lookback strength, channel width (standard deviation multiplier), max historical channels, zone merge distance, breakout penetration threshold, and full color customization.
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Built for traders who think in terms of market structure, not just indicators.
A multi-layered trend structure engine that combines regression-based diagonal channels, supply & demand zones, and smart breakout detection into a single unified overlay.
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
🔹 WHAT IT DOES
This indicator builds a complete structural map of the market by layering three analytical systems:
1 — Trend Channels (Essential + Secondary)
Automatically detects swing pivots and fits linear regression channels across each completed trend leg. Channels are rendered as diagonal lines with shaded fills — visually identical to TradingView's built-in Regression Trend drawing tool, but fully automated. Two independent layers work simultaneously:
• Essential Trend — captures dominant market structure using higher-strength pivots. Channels are colored green (bullish legs) or red (bearish legs) based on structural direction.
• Secondary Trend — captures shorter-term structure within the essential trend. Channels are rendered in grey to visually separate them from the primary structure.
Both layers preserve full historical channels on the chart, giving you a complete visual record of how the trend has evolved over time.
2 — Forming Channel (Live)
A real-time channel drawn from the last confirmed pivot to the current bar. It updates on every new candle, showing you the trend leg that is actively developing — before it becomes a confirmed historical channel. Rendered in a distinct color with dashed lines so you can immediately distinguish it from completed channels.
3 — Supply & Demand Zones
Pivot-based zone detection using candle body mapping. Zones are qualified by departure strength — only pivots with meaningful follow-through moves generate zones. Features include:
• Automatic zone merging when nearby zones overlap
• Freshness tracking: fresh (untested) → retested → weakened → invalidated
• Zones auto-remove when price breaks through with conviction
• Centered labels: SUPPLY / DEMAND with freshness indicators
4 — Smart Breakout Signals
Detects when price closes beyond the latest secondary channel boundary. Includes:
• Minimum penetration filter (in ATR multiples) to eliminate marginal breakouts
• Optional volume confirmation
• Trend alignment filter — only signals that agree with the essential trend direction
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
🔹 HOW TREND DIRECTION WORKS
Unlike indicators that determine trend from a moving average or the last candle's slope, this indicator uses structural market analysis:
• Tracks successive pivot highs and pivot lows
• Higher High + Higher Low = Bullish structure
• Lower High + Lower Low = Bearish structure
This means the dashboard won't flip bearish just because price made a normal pullback within an uptrend. It reflects the actual market structure.
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
🔹 HOW TO USE IT
Essential + Secondary channels give you the structural framework — trade in the direction of the essential trend, use secondary channels for timing.
Supply & Demand zones provide confluence — a breakout signal firing near a fresh demand zone in a bullish essential trend is a high-probability setup.
The info table (top-right) shows: essential and secondary trend direction, alignment status (ALIGNED / DIVERGENT), R² values for channel quality, and zone counts.
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
🔹 ALERTS
• Bullish / Bearish breakout (with-trend filtered)
• Any secondary channel break (unfiltered)
• Price entering supply or demand zones
• Confluence alerts: breakout + zone overlap
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
🔹 SETTINGS
All layers can be independently enabled/disabled. Key parameters include swing lookback strength, channel width (standard deviation multiplier), max historical channels, zone merge distance, breakout penetration threshold, and full color customization.
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Built for traders who think in terms of market structure, not just indicators.
오픈 소스 스크립트
트레이딩뷰의 진정한 정신에 따라, 이 스크립트의 작성자는 이를 오픈소스로 공개하여 트레이더들이 기능을 검토하고 검증할 수 있도록 했습니다. 작성자에게 찬사를 보냅니다! 이 코드는 무료로 사용할 수 있지만, 코드를 재게시하는 경우 하우스 룰이 적용된다는 점을 기억하세요.
면책사항
해당 정보와 게시물은 금융, 투자, 트레이딩 또는 기타 유형의 조언이나 권장 사항으로 간주되지 않으며, 트레이딩뷰에서 제공하거나 보증하는 것이 아닙니다. 자세한 내용은 이용 약관을 참조하세요.
오픈 소스 스크립트
트레이딩뷰의 진정한 정신에 따라, 이 스크립트의 작성자는 이를 오픈소스로 공개하여 트레이더들이 기능을 검토하고 검증할 수 있도록 했습니다. 작성자에게 찬사를 보냅니다! 이 코드는 무료로 사용할 수 있지만, 코드를 재게시하는 경우 하우스 룰이 적용된다는 점을 기억하세요.
면책사항
해당 정보와 게시물은 금융, 투자, 트레이딩 또는 기타 유형의 조언이나 권장 사항으로 간주되지 않으며, 트레이딩뷰에서 제공하거나 보증하는 것이 아닙니다. 자세한 내용은 이용 약관을 참조하세요.