OPEN-SOURCE SCRIPT
channeller pro

Channeller Pro - Statistical Price Channel Detection
What This Script Does
Channeller Pro identifies and draws price channels using pivot points, linear regression, and quality filters. It detects bullish and bearish channels and draws support/resistance lines with quality metrics.
Originality & Methodology
This script combines:
Pivot Point Detection: Uses TradingView's ta.pivothigh() and ta.pivotlow() with configurable left/right lookback to identify swing highs and lows.
Linear Regression Analysis: Fits a least-squares regression line through detected pivot points to determine channel slope and intercept.
R² Quality Scoring: Calculates the coefficient of determination (R²) to measure regression fit quality. R² values closer to 1.0 indicate stronger linear alignment of pivots. Channels below the minimum R² threshold are filtered out.
Pattern Validation:
Bullish channels require higher lows (ascending pivot lows)
Bearish channels require lower highs (descending pivot highs)
This ensures channels align with trend structure
ADX Trend Filter: Uses Average Directional Index (ADX) to show channels only when trend strength exceeds a threshold, reducing false signals in choppy markets.
Volume Confirmation (optional): Filters channels based on volume exceeding a moving average threshold.
Dynamic Channel Width: Calculates channel width by finding the maximum deviation from the regression line within the pivot range, then draws parallel support/resistance lines.
Channel Invalidation Logic: Tracks bounces and pierces. Channels are invalidated after multiple pierces through support/resistance, ensuring only active channels are displayed.
How It Works
Detection Process:
Identifies pivot highs/lows using the specified lookback periods
Stores recent pivots in arrays (configurable max count)
When minimum pivot count is reached, calculates linear regression through pivot points
Validates the channel by checking:
R² score meets minimum threshold (default 0.7)
Slope direction matches trend (positive for bullish, negative for bearish)
Pattern structure (higher lows for bullish, lower highs for bearish)
ADX exceeds threshold (if enabled)
Volume confirmation (if enabled)
If valid, draws support/resistance lines parallel to the regression line
Continuously monitors for channel breaks and invalidates when pierced multiple times
Mathematical Foundation:
Linear regression uses least squares: y = slope × x + intercept
R² calculation: R² = 1 - (SS_res / SS_tot) where SS_res is residual sum of squares and SS_tot is total sum of squares
Channel width = maximum price deviation from regression line within pivot range
How to Use
Basic Setup:
Apply the indicator to your chart
Adjust "Pivot Lookback Left/Right" to control pivot sensitivity (default 10 bars each)
Set "Min Pivots for Channel" (default 3) - higher values require more confirmation but reduce false signals
Configure "Min R² Score" (default 0.7) - higher values show only the best-fitting channels
Filter Configuration:
ADX Filter: Enable to show channels only during trending conditions (ADX > threshold)
Volume Filter: Enable to require volume confirmation for channel formation
HL/LH Pattern: Keep enabled to ensure channels follow proper trend structure
Trading Applications:
Support/Resistance: Use channel boundaries as dynamic support/resistance levels
Trend Following: Trade bounces off channel boundaries in the direction of the trend
Breakout Trading: Monitor for channel breaks as potential trend reversal signals
Channel Quality: Higher R² scores (displayed in labels) indicate stronger, more reliable channels
Display Options:
Toggle channel fills, mid-lines, pivot markers, and labels
Adjust projection length to extend channels into the future
Customize colors for bullish/bearish channels
Alerts:
The script includes alerts for:
New channel formation
Channel break/invalidation
New pivot detection
Important Notes
Channels are statistical constructs based on historical pivot points and do not guarantee future price action
R² scores indicate fit quality, not trading performance
Channels may be invalidated as market conditions change
Past channel performance does not predict future results
Always use proper risk management and combine with other analysis methods
Technical Details
Built-in Pine Script v6
Uses arrays for pivot storage and management
Implements custom linear regression calculation
Real-time channel validation and invalidation
Configurable quality thresholds and filters
What This Script Does
Channeller Pro identifies and draws price channels using pivot points, linear regression, and quality filters. It detects bullish and bearish channels and draws support/resistance lines with quality metrics.
Originality & Methodology
This script combines:
Pivot Point Detection: Uses TradingView's ta.pivothigh() and ta.pivotlow() with configurable left/right lookback to identify swing highs and lows.
Linear Regression Analysis: Fits a least-squares regression line through detected pivot points to determine channel slope and intercept.
R² Quality Scoring: Calculates the coefficient of determination (R²) to measure regression fit quality. R² values closer to 1.0 indicate stronger linear alignment of pivots. Channels below the minimum R² threshold are filtered out.
Pattern Validation:
Bullish channels require higher lows (ascending pivot lows)
Bearish channels require lower highs (descending pivot highs)
This ensures channels align with trend structure
ADX Trend Filter: Uses Average Directional Index (ADX) to show channels only when trend strength exceeds a threshold, reducing false signals in choppy markets.
Volume Confirmation (optional): Filters channels based on volume exceeding a moving average threshold.
Dynamic Channel Width: Calculates channel width by finding the maximum deviation from the regression line within the pivot range, then draws parallel support/resistance lines.
Channel Invalidation Logic: Tracks bounces and pierces. Channels are invalidated after multiple pierces through support/resistance, ensuring only active channels are displayed.
How It Works
Detection Process:
Identifies pivot highs/lows using the specified lookback periods
Stores recent pivots in arrays (configurable max count)
When minimum pivot count is reached, calculates linear regression through pivot points
Validates the channel by checking:
R² score meets minimum threshold (default 0.7)
Slope direction matches trend (positive for bullish, negative for bearish)
Pattern structure (higher lows for bullish, lower highs for bearish)
ADX exceeds threshold (if enabled)
Volume confirmation (if enabled)
If valid, draws support/resistance lines parallel to the regression line
Continuously monitors for channel breaks and invalidates when pierced multiple times
Mathematical Foundation:
Linear regression uses least squares: y = slope × x + intercept
R² calculation: R² = 1 - (SS_res / SS_tot) where SS_res is residual sum of squares and SS_tot is total sum of squares
Channel width = maximum price deviation from regression line within pivot range
How to Use
Basic Setup:
Apply the indicator to your chart
Adjust "Pivot Lookback Left/Right" to control pivot sensitivity (default 10 bars each)
Set "Min Pivots for Channel" (default 3) - higher values require more confirmation but reduce false signals
Configure "Min R² Score" (default 0.7) - higher values show only the best-fitting channels
Filter Configuration:
ADX Filter: Enable to show channels only during trending conditions (ADX > threshold)
Volume Filter: Enable to require volume confirmation for channel formation
HL/LH Pattern: Keep enabled to ensure channels follow proper trend structure
Trading Applications:
Support/Resistance: Use channel boundaries as dynamic support/resistance levels
Trend Following: Trade bounces off channel boundaries in the direction of the trend
Breakout Trading: Monitor for channel breaks as potential trend reversal signals
Channel Quality: Higher R² scores (displayed in labels) indicate stronger, more reliable channels
Display Options:
Toggle channel fills, mid-lines, pivot markers, and labels
Adjust projection length to extend channels into the future
Customize colors for bullish/bearish channels
Alerts:
The script includes alerts for:
New channel formation
Channel break/invalidation
New pivot detection
Important Notes
Channels are statistical constructs based on historical pivot points and do not guarantee future price action
R² scores indicate fit quality, not trading performance
Channels may be invalidated as market conditions change
Past channel performance does not predict future results
Always use proper risk management and combine with other analysis methods
Technical Details
Built-in Pine Script v6
Uses arrays for pivot storage and management
Implements custom linear regression calculation
Real-time channel validation and invalidation
Configurable quality thresholds and filters
오픈 소스 스크립트
트레이딩뷰의 진정한 정신에 따라, 이 스크립트의 작성자는 이를 오픈소스로 공개하여 트레이더들이 기능을 검토하고 검증할 수 있도록 했습니다. 작성자에게 찬사를 보냅니다! 이 코드는 무료로 사용할 수 있지만, 코드를 재게시하는 경우 하우스 룰이 적용된다는 점을 기억하세요.
면책사항
해당 정보와 게시물은 금융, 투자, 트레이딩 또는 기타 유형의 조언이나 권장 사항으로 간주되지 않으며, 트레이딩뷰에서 제공하거나 보증하는 것이 아닙니다. 자세한 내용은 이용 약관을 참조하세요.
오픈 소스 스크립트
트레이딩뷰의 진정한 정신에 따라, 이 스크립트의 작성자는 이를 오픈소스로 공개하여 트레이더들이 기능을 검토하고 검증할 수 있도록 했습니다. 작성자에게 찬사를 보냅니다! 이 코드는 무료로 사용할 수 있지만, 코드를 재게시하는 경우 하우스 룰이 적용된다는 점을 기억하세요.
면책사항
해당 정보와 게시물은 금융, 투자, 트레이딩 또는 기타 유형의 조언이나 권장 사항으로 간주되지 않으며, 트레이딩뷰에서 제공하거나 보증하는 것이 아닙니다. 자세한 내용은 이용 약관을 참조하세요.