OPEN-SOURCE SCRIPT

Commodity Channel Index Dual

29
The CCI Dual is a custom TradingView indicator built in Pine Script v5, designed to help traders identify potential buy and sell signals using two Commodity Channel Index (CCI) oscillators. It combines a shorter-period CCI (default: 14) for quick momentum detection with a longer-period CCI (default: 50) for confirmation, focusing on mean-reversion opportunities in overbought or oversold conditions.

This setup is particularly suited for volatile markets like cryptocurrencies on higher timeframes (e.g., 3-day charts), where it highlights reversals by requiring both CCIs to cross out of extreme zones within a short window (default: 3 bars).
The indicator plots the CCIs, customizable bands (inner: 100, OB/OS: 175, outer: 200), dynamic fills for visual emphasis, background highlights for signals, and alert conditions for notifications.

How It Works
The indicator calculates two CCIs based on user-defined lengths and source (default: close price):
CCI Calculation: CCI measures price deviation from its average, using the formula: CCI = (Typical Price - Simple Moving Average) / (0.015 * Mean Deviation). The short CCI reacts faster to price changes, while the long CCI provides smoother, trend-aware confirmation.

Overbought/Oversold Levels: Customizable thresholds define extremes (Overbought at +175, Oversold at -175 by default). Bands are plotted at inner (±100), mid (±175 dashed), and outer (±200) levels, with gray fills for the outer zones.

Dynamic Fills: The longer CCI is used to shade areas beyond OB/OS levels in red (overbought) or green (oversold) for quick visual cues.

Signals:
Buy Signal: Triggers when both CCIs cross above the Oversold level (-175) within the signal window (3 bars). This suggests a potential upward reversal from an oversold state.
Sell Signal: Triggers when both cross below the Overbought level (+175) within the window, indicating a possible downward reversal.

Visuals and Alerts: Buy signals highlight the background green, sells red. Separate alertconditions allow setting TradingView alerts for buys or sells independently.
Customization: Adjust lengths, levels, and window via inputs to fit your timeframe or asset—e.g., higher OB/OS for crypto volatility.

This logic reduces noise by requiring dual confirmation, but like all oscillators, it can produce false signals in strong trends where prices stay extended.

To mitigate false signals (e.g., in trending markets), layer the CCI Dual with MACD (default: 12,26,9) and RSI (default: 14) for multi-indicator confirmation:

With MACD: Only take CCI buys if the MACD line is above the signal line (or histogram positive), confirming bullish momentum. For sells, require MACD bearish crossover. This filters counter-trend signals by aligning with trend strength—e.g., ignore CCI sells if MACD shows upward momentum.

With RSI: Confirm CCI oversold buys only if RSI is below 30 and rising (or shows bullish divergence). For overbought sells, RSI above 70 and falling. This adds overextension validation, reducing whipsaws in crypto trends.

I made this customizable for you to find what works best for your asset you are trading. I trade the 6 hour and 3 day timeframe mainly on major cryptocurrency pairs. I hope you enjoy this script and it serves you well.

Clause de non-responsabilité

Les informations et les publications ne sont pas destinées à être, et ne constituent pas, des conseils ou des recommandations en matière de finance, d'investissement, de trading ou d'autres types de conseils fournis ou approuvés par TradingView. Pour en savoir plus, consultez les Conditions d'utilisation.