Indicator: CCI coded OBV

Apr 3, 2014

Static chart image
Volume Based
Signals
Oscillators
Divergences
Moving Averages

The CCI coded OBV indicator merges On-Balance Volume (OBV) with Commodity Channel Index (CCI) logic to provide a volume-based momentum oscillator that visually identifies trend shifts and price-volume divergence.

Usage

The Usage section focuses on the integration of volume trend and momentum sentiment. Traders can use the color-coded OBV line to determine if the current volume flow is supported by momentum as defined by the CCI. When the OBV line is green, it indicates that volume is accumulating while CCI is above the user-defined threshold, suggesting bullish momentum. Conversely, a red OBV line indicates that CCI has fallen below the threshold, suggesting bearish momentum or distribution.

The inclusion of an Exponential Moving Average (EMA) provides a baseline for trend direction and potential crossover signals. A common strategy involves monitoring for crossovers between the OBV line and its EMA:

  • Bullish Signal: The OBV line crosses above the EMA while colored green.
  • Bearish Signal: The OBV line crosses below the EMA while colored red.

Details

The script calculates On-Balance Volume (OBV) by keeping a running total of volume based on whether the current closing price is higher or lower than the previous close. It then calculates the Commodity Channel Index (CCI) based on a specified lookback period.

The core logic applies a conditional coloring to the OBV plot: if the CCI value is greater than or equal to the "CCI threshold," the plot displays a bullish color; if the CCI is below the threshold, it displays a bearish color. This allows users to filter volume movements through a momentum-based lens. The EMA is applied directly to the OBV data to smooth the output and provide a signal line for trend following.

Settings

  • CCI Length: Determines the lookback period used for the Commodity Channel Index calculation.
  • CCI threshold for OBV coding: The level at which the OBV line changes color. Setting this to 0 ensures color changes occur at the CCI baseline.
  • EMA length: Sets the number of periods for the Exponential Moving Average plotted over the OBV.

FAQ

How do I interpret the color changes on the OBV line?

The color changes represent the relationship between momentum and volume. A green line indicates the CCI is above your threshold (typically implying bullish momentum), while a red line indicates the CCI is below the threshold (implying bearish momentum).

Can I use this for divergence trading?

Yes, users can look for instances where price makes a new high but the CCI coded OBV fails to make a new high or remains red, which may indicate weakening buying pressure.

How do I access this indicator?

You can get access on the LuxAlgo Library for charting platforms like TradingView, MetaTrader (MT4/MT5), and NinjaTrader for free.

Free access on the following platforms
tradingviewSymbolTradingView
ninjatraderNinjaTrader
metatrader4MetaTrader 4/5
thinkorswimThinkorswim

Unlock Unlimited Access to the LuxAlgo Library

Upgrade your plan to get all indicators, strategies, charts, and full access to Quant, our AI agent.

Trading & investing are risky and many will lose money in connection with trading and investing activities. All content on this site is not intended to, and should not be, construed as financial advice. Decisions to buy, sell, hold or trade in securities, commodities and other investments involve risk and are best made based on the advice of qualified financial professionals. Past performance does not guarantee future results.

Hypothetical or Simulated performance results have certain limitations. Unlike an actual performance record, simulated results do not represent actual trading. Also, since the trades have not been executed, the results may have under-or-over compensated for the impact, if any, of certain market factors, including, but not limited to, lack of liquidity. Simulated trading programs in general are designed with the benefit of hindsight, and are based on historical information. No representation is being made that any account will or is likely to achieve profit or losses similar to those shown.

Testimonials appearing on this website may not be representative of other clients or customers and is not a guarantee of future performance or success.

As a provider of technical analysis tools and strategies, we do not have access to the personal trading accounts or brokerage statements of our customers. As a result, we have no reason to believe our customers perform better or worse than traders as a whole based on any content, tool, or platform feature we provide.

Charts used on this site are by TradingView in which the majority of our technical indicators are built on. TradingView® is a registered trademark of TradingView, Inc. www.TradingView.com TradingView® has no affiliation with the owner, developer, or provider of the Services described herein.

Market data is provided by CBOE, CME Group, BarChart, Massive, CoinAPI. Select U.S. equities data is provided through Massive. CBOE BZX real-time U.S. equities data is licensed from CBOE and provided through BarChart. Real-time futures data is licensed from CME Group and provided through BarChart. Select cryptocurrency data, including major coins, is provided through CoinAPI. All data is provided “as is” and should be verified independently for trading purposes.

This does not represent our full Disclaimer. Please read our full disclaimer.

© 2026 LuxAlgo Global, LLC.