OPEN-SOURCE SCRIPT

channeller pro

123
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

Haftungsausschluss

Die Informationen und Veröffentlichungen sind nicht als Finanz-, Anlage-, Handels- oder andere Arten von Ratschlägen oder Empfehlungen gedacht, die von TradingView bereitgestellt oder gebilligt werden, und stellen diese nicht dar. Lesen Sie mehr in den Nutzungsbedingungen.