OPEN-SOURCE SCRIPT

CCI Divergence Detector

1 049

A technical analysis tool that identifies divergences between price action and the Commodity Channel Index (CCI) oscillator. Unlike standard divergence indicators, this system employs advanced gradient visualization, multi-layer wave effects, and comprehensive customization options to provide traders with crystal-clear divergence signals and market momentum insights.

<bold>Core Detection Mechanism</bold>
<bold>CCI-Based Analysis:</bold> The indicator utilizes the Commodity Channel Index as its primary oscillator, calculated from user-configurable source data (default: HLC3) with adjustable length parameters. The CCI provides reliable momentum readings that effectively highlight price-momentum divergences.

<bold>Dynamic Pivot Detection:</bold> The system employs adaptive pivot detection with three sensitivity levels (High/Normal/Low) to identify significant highs and lows in both price and CCI values. This dynamic approach ensures optimal divergence detection across different market conditions and timeframes.

<bold>Dual Divergence Analysis:</bold>
<bold>Regular Bullish Divergences:</bold> Detected when price makes lower lows while CCI makes higher lows, indicating potential upward reversal

<bold>Regular Bearish Divergences:</bold> Identified when price makes higher highs while CCI makes lower highs, signaling potential downward reversal

<bold>Strength Classification System:</bold> Each detected divergence is automatically classified into three strength categories (Weak/Moderate/Strong) based on:
-Price differential magnitude
-CCI differential magnitude
-Time duration between pivot points
-User-configurable strength multiplier

<bold>Advanced Visual System</bold>
<bold>Multi-Layer Wave Effects:</bold> The indicator features a revolutionary wave visualization system that creates depth through multiple gradient layers around the CCI line. The wave width dynamically adjusts based on ATR volatility, providing intuitive visual feedback about market conditions.

<bold>Professional Color Gradient System:</bold> Nine independent color inputs control every visual aspect:
<bold>Bullish Colors (Light/Medium/Dark):</bold> Control oversold areas, wave effects, and strong bullish signals
<bold>Bearish Colors (Light/Medium/Dark):</bold> Manage overbought zones, wave fills, and strong bearish signals
<bold>Neutral Colors (Light/Medium/Dark):</bold> Handle table elements, zero line, and transitional states

<bold>Intelligent Color Mapping:</bold> Colors automatically adapt based on CCI values:
Overbought territory (>100): Bearish color gradients with increasing intensity
Neutral positive (0 to 100): Blend from neutral to bearish tones
Oversold territory (<-100): Bullish color gradients with increasing intensity
Neutral negative (-100 to 0): Transition from neutral to bullish tones

<bold>Key Features & Components</bold>
<bold>Advanced Configuration System:</bold> Eight organized input groups provide granular control:
<bold>General Settings:</bold> System enable, pivot length, confidence thresholds
<bold>Oscillator Selection:</bold> CCI parameters, overbought/oversold levels, normalization options
<bold>Detection Parameters:</bold> Divergence types, minimum strength requirements
<bold>Sensitivity Tuning:</bold> Pivot sensitivity, divergence threshold, confirmation bars
<bold>Visual System:</bold> Line thickness, labels, backgrounds, table display
<bold>Wave Effects:</bold> Dynamic width, volatility response, layer count, glow effects
<bold>Transparency Controls:</bold> Independent transparency for all visual elements
<bold>Smoothing & Filtering:</bold> CCI smoothing types, noise filtering, wave smoothing
<bold>Professional Alert System:</bold> Comprehensive alert functionality with dynamic messages including:
-Divergence type and strength classification
-Current CCI value and confidence percentage
-Customizable alert frequency and conditions

<bold>Enhanced Information Table:</bold> Real-time display showing:
-Current CCI length and value
-Market status (Overbought/Normal/Oversold)
-Active sensitivity setting

Configurable table positioning (4 corner options)
<bold>Visual Elements Explained</bold>
<bold>Primary CCI Line:</bold> Main oscillator plot with gradient coloring that reflects market momentum and CCI intensity. Line thickness is user-configurable (1-8 pixels).
<bold>Wave Effect Layers:</bold> Multi-layer gradient fills creating a dynamic wave around the
CCI line:
-Outer layers provide broad market context
-Inner layers highlight immediate momentum
-Core layers show precise CCI movement
-All layers respond to volatility and momentum changes

<bold>Divergence Lines & Labels:</bold>
-Solid lines connecting divergence pivot points
-Color-coded based on divergence type and strength
-Labels displaying divergence type and strength classification
-Customizable transparency and size options

<bold>Reference Lines:</bold>
-Zero line with neutral color coding
-Overbought level (default: 100) with bearish coloring
-Oversold level (default: -100) with bullish coloring

<bold>Background Gradient:</bold> Optional background coloring that reflects CCI intensity and market conditions with user-controlled transparency (80-99%).

<bold>Configuration Options</bold>
<bold>Sensitivity Controls:</bold>
Pivot sensitivity: High/Normal/Low detection levels
Divergence threshold: 0.1-2.0 sensitivity range
Confirmation bars: 1-5 bar confirmation requirement
Strength multiplier: 0.1-3.0 calculation adjustment

<bold>Visual Customization:</bold>
Line transparency: 0-90% for main elements
Wave transparency: 0-95% for fill effects
Background transparency: 80-99% for subtle background
Label transparency: 0-50% for text elements
Glow transparency: 50-95% for glow effects

<bold>Advanced Processing:</bold>
Five smoothing types: None/SMA/EMA/RMA/WMA
Noise filtering with adjustable threshold (0.1-10.0)
CCI normalization for enhanced gradient scaling
Dynamic wave width with ATR-based volatility response

<bold>Interpretation Guidelines</bold>
<bold>Divergence Signals:</bold>
<bold>Strong divergences:</bold> High-confidence reversal signals requiring immediate attention
<bold>Moderate divergences:</bold> Reliable signals suitable for most trading strategies
<bold>Weak divergences:</bold> Early warning signals best combined with additional confirmation
<bold>Wave Intensity:</bold> Wave width and color intensity provide real-time volatility and momentum feedback. Wider, more intense waves indicate higher market volatility and stronger momentum.

<bold>Color Transitions:</bold> Smooth color transitions between bullish, neutral, and bearish states help identify market regime changes and momentum shifts.
<bold>CCI Levels:</bold> Traditional overbought (>100) and oversold (<-100) levels remain relevant, but the gradient system provides more nuanced momentum reading between these extremes.

<bold>Technical Specifications</bold>
<bold>Compatible Timeframes:</bold> All timeframes supported
<bold>Maximum Labels:</bold> 500 (for divergence marking)
<bold>Maximum Lines:</bold> 500 (for divergence drawing)
<bold>Pine Script Version:</bold> v5 (latest optimization)
<bold>Overlay Mode:</bold> False (separate pane indicator)
<bold>Usage Recommendations</bold>

This indicator works best when:
-Combined with price action analysis and support/resistance levels
-Used across multiple timeframes for confirmation
-Integrated with proper risk management protocols
-Applied in trending markets for divergence-based reversal signals
-Utilized with other technical indicators for comprehensive analysis

<bold>Risk Disclaimer:</bold> Trading involves substantial risk of loss. This indicator is provided for analytical purposes only and does not constitute financial advice. Divergence signals, while powerful, are not guaranteed to predict future price movements. Past performance is not indicative of future results. Always use proper risk management and never trade with capital you cannot afford to lose.

Penafian

Maklumat dan penerbitan adalah tidak dimaksudkan untuk menjadi, dan tidak membentuk, nasihat untuk kewangan, pelaburan, perdagangan dan jenis-jenis lain atau cadangan yang dibekalkan atau disahkan oleh TradingView. Baca dengan lebih lanjut di Terma Penggunaan.