OPEN-SOURCE SCRIPT
Aktualisiert

Commodity Channel Index - CCI | TR

59
🎯 Overview
Commodity Channel Index - CCI | TR is a versatile momentum oscillator that measures the current price level relative to an average price over a specified period. Developed by Tiagorocha1989, this enhanced version of Donald Lambert's classic CCI indicator offers dual-mode operation with moving average customization and comprehensive visual features, helping traders identify overbought and oversold conditions, detect trend strength, and generate clear entry and exit signals.

🔧 How It Works
The CCI measures the deviation of a typical price (usually the average of high, low, and close) from its statistical mean, normalized by the mean deviation. Values oscillate above and below zero, with extreme readings suggesting potential reversals.

Core Calculation Logic:
The indicator calculates the CCI using the standard formula:

Typical Price = (High + Low + Close) / 3

SMA of Typical Price over the specified period

Mean Deviation = Average of absolute differences between Typical Price and its SMA

CCI = (Typical Price - SMA) / (0.015 × Mean Deviation)

The resulting oscillator typically fluctuates between +300 and -300, with:

Readings above +100 suggesting overbought conditions (potential reversal down)

Readings below -100 suggesting oversold conditions (potential reversal up)

Zero line representing the average level

The indicator compares CCI to a reference line that can be either:

The traditional zero level

A user-defined moving average of the CCI itself (CCI MA mode)

✨ Key Features
🔹 Dual Operating Modes
Zero Line Mode: Classic CCI implementation where signals occur when CCI crosses above or below the zero line

CCI MA Mode: Enhanced version where signals occur when CCI crosses its own moving average, providing smoother, filtered entries

🔹 Flexible Moving Average Selection
Choose from six MA types for the CCI MA mode:

EMA (Exponential Moving Average) for responsive signals

SMA (Simple Moving Average) for smoother readings

RMA (Rolling Moving Average) for weighted recent data

WMA (Weighted Moving Average) for customizable weighting

VWMA (Volume-Weighted Moving Average) incorporating volume

HMA (Hull Moving Average) for reduced lag

🔹 Customizable CCI Parameters
Length CCI: Lookback period for CCI calculation (default 55)

Source CCI: Price source for calculations (default Close)

🔹 Customizable Color Themes
Eight distinct color schemes to match your charting preferences:

Classic – Green for bullish, Red for bearish

Modern – White for bullish, Purple for bearish

Robust – Amber for bullish, Maroon for bearish

Accented – Violet for bullish, Pink for bearish

Monochrome – Light gray for bullish, Dark gray for bearish

Moderate – Green for bullish, Red for bearish

Aqua – Blue for bullish, Orange for bearish

Cosmic – Pink for bullish, Purple for bearish

🔹 Comprehensive Visual Feedback
Colored CCI Line: Changes color based on position relative to the reference line

Signal Line: Yellow line showing zero or MA reference

Gradient Fill Zones: Clear visualization of overbought (above +300) and oversold (below -300) conditions

Dynamic Zone Fills: Semi-transparent fills showing when CCI is above or below the reference line

Color-Coded Candles: Bars reflect current CCI bias (above or below 50)

Signal Markers: Triangle up/down symbols at crossover points

Live Value Display: Current CCI value shown in a floating label

Trend Table: Bullish/Bearish status displayed on the chart

🔹 Ready-to-Use Alerts
Built-in alert conditions trigger LONG signals when CCI is above zero/bullish, and SHORT signals when CCI is below zero/bearish.

⚙️ Settings Summary
Color Choice: Select from eight visual themes (Default: Classic)

Length CCI: Lookback period for CCI calculation (Default: 55)

Source CCI: Price source for calculations (Default: Close)

Entry/Exit Signal: Choose between zero line or CCI MA mode (Default: Zero Line)

Length MA: Moving average period for CCI MA mode (Default: 365)

CCI MA Type: Moving average method for signal line (Default: EMA)

📈 Practical Applications
🔹 Overbought/Oversold Detection
Traditional CCI usage identifies extreme conditions:

Readings above +100 suggest overbought conditions and potential reversal down

Readings below -100 suggest oversold conditions and potential reversal up

The indicator provides gradient fills in these zones for visual clarity

The 300-level fills provide even more extreme zone visualization

🔹 Zero Line Crossovers
In Zero Line mode, crossovers provide momentum signals:

Crossover above zero → Bullish momentum strengthening

Crossunder below zero → Bearish momentum strengthening

These signals often align with trend direction changes

🔹 Signal Line Crossovers
In CCI MA mode, crossovers between CCI and its moving average provide filtered signals that reduce whipsaws in ranging markets while maintaining sensitivity in trends.

🔹 Divergence Trading
CCI is excellent for spotting divergences:

Bullish Divergence: Price makes lower low, CCI makes higher low → Potential upside reversal

Bearish Divergence: Price makes higher high, CCI makes lower high → Potential downside reversal

Divergences are most significant when occurring at extreme levels (+100/-100)

🔹 Centerline Confirmation
The 50 level (used for candle coloring) provides additional context:

CCI above 50 → Stronger bullish bias

CCI below 50 → Stronger bearish bias

This can be used as a filter for other signals

🔹 Trend Strength Assessment
The magnitude of CCI readings indicates trend strength:

Readings consistently above +100 suggest strong uptrend

Readings consistently below -100 suggest strong downtrend

Fluctuations around zero suggest ranging conditions

🔹 Multiple Timeframe Analysis
The normalized nature of CCI makes it suitable for comparing readings across different timeframes, helping identify confluence for stronger trade setups.

🎯 Ideal For
✅ Mean Reversion Traders seeking overbought and oversold opportunities

✅ Divergence Traders looking for hidden reversal signals

✅ Momentum Traders wanting to identify trend strength and direction

✅ Swing Traders capturing medium-term momentum shifts

✅ Commodity and Forex Traders (originally designed for commodities but works across all markets)

📌 Key Takeaways
Dual-Mode Flexibility: Choose between classic zero-line crossovers for traditional signals or MA-smoothed signals for filtered entries

Comprehensive Visualization: Color themes, gradient fills for overbought/oversold zones, candles, and labels provide immediate market awareness

Divergence Capability: Excellent for spotting both regular and hidden divergences that signal trend reversals or continuations

Extended Range Visualization: The 300-level gradient fills provide clear identification of extreme conditions

Alert-Ready: Built-in alerts for both LONG and SHORT signals

⚠️ Important Notes
In strong trends, CCI can remain in overbought or oversold territory for extended periods, so traditional overbought/oversold signals should be used with caution. The default length of 55 is longer than traditional CCI settings (typically 20), making this version more suitable for medium to longer-term trend identification. The 365-day MA default in CCI MA mode is designed for longer-term trend context on daily charts. Divergences are most reliable when they occur at extreme readings (above +100 or below -100). Always combine with proper risk management and additional confirmation for best results.

Disclaimer: This indicator is provided for educational and informational purposes only. Past performance is not indicative of future results. Always conduct thorough testing and align with your risk management strategy before live deployment.
Versionshinweise
Resolution of previous problem

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.