Logo
OFFLINEPIXEL
/ pinescript-strategies / pine-script-chaikin-volatility

$ Pinescript Chaikin Volatility

Master this versatile volatility indicator in TradingView's Pinescript that quantifies market uncertainty and identifies potential turning points based on price range expansion and contraction.

500+ Clients Helped
100% Satisfaction
Live Trading Ready
⚠️
Trading financial markets carries risk. All content (PineScript code, indicators, strategies) on this website is for educational purposes only. Past performance is not indicative of future results. By using any code or information from this site, you agree that you are solely responsible for your trading decisions. The author disclaims all liability for any losses incurred. To gain from experts experiences, You can always try our Invite Only Scripts
01

What is Chaikin Volatility?

Chaikin Volatility (CV), developed by Marc Chaikin (creator of the Chaikin Money Flow and Chaikin Oscillator), is a technical indicator that measures volatility by quantifying the spread between the high and low prices over a specific period. It uses an Exponential Moving Average (EMA) of the difference between the highest and lowest prices over a given lookback period, and then calculates the percentage change of this EMA from a prior period.

The primary use of Chaikin Volatility is to indicate whether the market is becoming more volatile (expanding ranges) or less volatile (contracting ranges). High CV values suggest increasing volatility, while low CV values suggest decreasing volatility. It can help traders anticipate potential breakouts or periods of consolidation, as well as confirm the strength of current trends.

In Pinescript, Chaikin Volatility offers a unique perspective on market uncertainty, complementing directional indicators by providing context on price action intensity.

02

Components and Calculation

The calculation of Chaikin Volatility involves a few steps:

  1. High-Low Range: For each bar, calculate `Range = High - Low`.
  2. EMA of High-Low Range: Calculate an EMA of this `Range` over a specified `emaLength` (e.g., 10 periods). Let's call this `HL_EMA`.
    `HL_EMA = ta.ema(Range, emaLength)`
  3. Percentage Change: Calculate the percentage change between the current `HL_EMA` and the `HL_EMA` from a `rocLength` periods ago (e.g., 10 periods).
    `Chaikin Volatility = ((HL_EMA - HL_EMA[rocLength]) / HL_EMA[rocLength]) * 100`
03

Basic Chaikin Volatility (CV) Implementation in Pinescript

pine-script@terminal
//@version=5
indicator("My Chaikin Volatility", overlay=false) // overlay=false to plot in a separate pane

// Inputs for Chaikin Volatility parameters
emaLength = input.int(10, title="EMA Length (HL Range)", minval=1)
rocLength = input.int(10, title="ROC Length (Volatility Change)", minval=1)

// Calculate Chaikin Volatility using the built-in function
// ta.cvol takes the EMA length and ROC length
cvValue = ta.cvol(emaLength, rocLength)

// Plot the Chaikin Volatility line
plot(cvValue, title="Chaikin Volatility", color=color.new(color.blue, 0), linewidth=2)

// Plot the Zero Line (can be used as a reference)
hline(0, "Zero Line", color.gray, linestyle=hline.style_dotted)

// Optional: Add reference levels for visual clarity, usually around +10% and -10% for typical assets
hline(10, "Upper Ref (+10%)", color=color.new(color.red, 0), linestyle=hline.style_dashed)
hline(-10, "Lower Ref (-10%)", color=color.new(color.green, 0), linestyle=hline.style_dashed)
$ ✓ Compiled successfully
04

Volatility Direction

Volatility Direction

A rising Chaikin Volatility line suggests increasing volatility. A falling line suggests decreasing volatility. Positive values mean current volatility is higher than `rocLength` periods ago; negative means lower.

05

Practical Chaikin Volatility Trading Strategies

1. Volatility Expansion and Breakouts

A surge in Chaikin Volatility from relatively low levels often signals that price is about to break out of a consolidation phase, initiating a strong directional move. This is a common strategy for trend-following setups.

  • Signal: Chaikin Volatility drops to low levels (indicating consolidation) and then suddenly rises sharply.
  • Trade Action: This signals an impending breakout. Combine with directional indicators (e.g., price breaking a trendline, moving average crossover, or a bullish/bearish candlestick pattern) to determine the direction of the breakout.
//@version=5
strategy("Chaikin Volatility Breakout Strategy", overlay=true)

emaLength = input.int(10, title="EMA Length", minval=1)
rocLength = input.int(10, title="ROC Length", minval=1)
volatilityThreshold = input.float(15.0, title="Volatility Surge Threshold (%)", minval=5.0, step=1.0)
consolidationThreshold = input.float(-5.0, title="Consolidation Threshold (%)", maxval=0.0, step=1.0)

cvValue = ta.cvol(emaLength, rocLength)

plot(cvValue, "Chaikin Volatility", color.blue, display=display.pane_only)
hline(0, "Zero Line", color.gray, linestyle=hline.style_dotted, display=display.pane_only)
hline(volatilityThreshold, "Surge Threshold", color.red, linestyle=hline.style_dashed, display=display.pane_only)
hline(consolidationThreshold, "Consolidation Threshold", color.green, linestyle=hline.style_dashed, display=display.pane_only)

// Detect periods of consolidation (low volatility)
isConsolidating = cvValue < consolidationThreshold

// Detect a volatility surge from consolidation
volatilitySurge = cvValue > volatilityThreshold and isConsolidating[1]

// Combine with a simple trend filter for direction on breakout (e.g., price crossing a short MA)
maLength = input.int(20, "Breakout MA Length", minval=1)
ma = ta.sma(close, maLength)

longBreakoutSignal = volatilitySurge and close > ma and close[1] <= ma[1]
shortBreakoutSignal = volatilitySurge and close < ma and close[1] >= ma[1]

if (longBreakoutSignal)
    strategy.entry("Long Breakout", strategy.long)

if (shortBreakoutSignal)
    strategy.entry("Short Breakout", strategy.short)

// Example exit: close on opposite MA cross or fixed stop/target
strategy.close("Long Breakout", when=close < ma)
strategy.close("Short Breakout", when=close > ma)

2. Volatility Contraction and Trend Exhaustion

A falling Chaikin Volatility from high levels suggests that the current trend is losing momentum and volatility is contracting. This can precede a trend reversal or a deep correction.

  • Signal: Chaikin Volatility is high (during a trend) and then begins to decline significantly.
  • Trade Action: This signals potential trend exhaustion. Look for price reversal patterns, divergence with other momentum indicators, or consider taking profits on existing trend trades.
//@version=5
indicator("Chaikin Volatility Trend Exhaustion", overlay=true)

emaLength = input.int(10, title="EMA Length", minval=1)
rocLength = input.int(10, title="ROC Length", minval=1)
highVolThreshold = input.float(15.0, title="High Volatility Threshold (%)", minval=5.0, step=1.0)
declineThreshold = input.float(-5.0, title="Volatility Decline Threshold (%)", maxval=0.0, step=1.0) // How much it needs to decline

cvValue = ta.cvol(emaLength, rocLength)

plot(cvValue, "Chaikin Volatility", color.blue)
hline(0, "Zero Line", color.gray, linestyle=hline.style_dotted)
hline(highVolThreshold, "High Vol Threshold", color.red, linestyle=hline.style_dashed)
hline(declineThreshold, "Decline Threshold", color.green, linestyle=hline.style_dashed)

// Detect if volatility was high and is now declining
isVolatilityDeclining = cvValue < cvValue[1] and cvValue < declineThreshold and cvValue[rocLength] > highVolThreshold

plotshape(isVolatilityDeclining, title="Trend Exhaustion Warning", location=location.abovebar, color=color.new(color.maroon, 0), style=shape.diamond, size=size.small)
alertcondition(isVolatilityDeclining, "CV Trend Exhaustion", "Chaikin Volatility indicating potential trend exhaustion.")

3. Divergence with Price

Divergence between price and Chaikin Volatility can be a powerful signal of an impending trend change. This suggests that the price movement is not being backed by corresponding volatility, implying weakness in the trend.

  • Bullish Divergence: Price makes a lower low, but Chaikin Volatility makes a higher low. This indicates weakening bearish momentum and increasing uncertainty, potentially leading to an upward reversal.
  • Bearish Divergence: Price makes a higher high, but Chaikin Volatility makes a lower high. This indicates weakening bullish momentum and decreasing uncertainty, potentially leading to a downward reversal.
//@version=5
indicator("Chaikin Volatility Divergence", overlay=true)

emaLength = input.int(10, title="EMA Length", minval=1)
rocLength = input.int(10, title="ROC Length", minval=1)

cvValue = ta.cvol(emaLength, rocLength)

plot(cvValue, "Chaikin Volatility", color.blue)
hline(0, "Zero Line", color.gray, linestyle=hline.style_dotted)

// Simple divergence detection (conceptual, robust detection requires advanced pivot logic)
// This is a simplified example focusing on price vs CV divergence.

// Bullish Divergence (Price lower low, CV higher low)
bullishDivergence = close[2] > close[1] and close[1] > close and cvValue[2] < cvValue[1] and cvValue[1] < cvValue

// Bearish Divergence (Price higher high, CV lower high)
bearishDivergence = close[2] < close[1] and close[1] < close and cvValue[2] > cvValue[1] and cvValue[1] > cvValue

plotshape(bullishDivergence, title="Bullish Divergence", location=location.belowbar, color=color.new(color.green, 0), style=shape.triangleup, size=size.small)
plotshape(bearishDivergence, title="Bearish Divergence", location=location.abovebar, color=color.new(color.red, 0), style=shape.triangledown, size=size.small)

alertcondition(bullishDivergence, "Bullish CV Divergence", "Potential bullish reversal based on Chaikin Volatility divergence.")
alertcondition(bearishDivergence, "Bearish CV Divergence", "Potential bearish reversal based on Chaikin Volatility divergence.")
06

Optimizing Chaikin Volatility Performance

To get the most from Chaikin Volatility in Pinescript:

  • Parameter Tuning: The default lengths (10 for EMA of HL range, 10 for ROC lookback) are common. Shorter lengths will make the indicator more sensitive to immediate price range changes. Longer lengths will smooth out the readings, providing a broader view of volatility trends. Experiment to find optimal settings for your asset and timeframe.
  • Combine with Directional Indicators: Chaikin Volatility is not a directional indicator. It tells you *about* volatility, not *where* price is going. Always use it in conjunction with trend-following indicators (e.g., moving averages, MACD, ADX) or price action analysis to determine the direction of the market's next move after a volatility signal.
  • Confluence with Price Action: A signal from Chaikin Volatility (e.g., a volatility surge) is stronger when confirmed by clear price action like a strong breakout above a key resistance level or a significant candlestick pattern.
  • Context is Key: Interpret Chaikin Volatility relative to its historical values for the specific asset. What's considered "high" or "low" volatility can vary significantly between different assets or timeframes.
  • Volume Analysis: Often, increasing volatility (rising CV) is accompanied by increasing volume. This confluence can add conviction to breakout signals.
07

Volatility Cycles

Volatility Cycles

Markets tend to cycle between periods of low volatility (consolidation) and high volatility (trending). Chaikin Volatility helps you identify these shifts, enabling you to adapt your trading style accordingly.

08

Common Chaikin Volatility Pitfalls

  • Not a Directional Signal: The most common mistake is attempting to derive buy/sell signals purely from Chaikin Volatility. It does not predict price direction.
  • Lag: As it uses moving averages, Chaikin Volatility has some inherent lag and will not always pinpoint the exact start of a volatility expansion or contraction.
  • False Signals: Like any indicator, it can generate false signals. A volatility surge doesn't always guarantee a successful breakout, and a decline doesn't always mean a reversal.
  • Subjective Interpretation of Levels: There are no universal "overbought" or "oversold" levels for Chaikin Volatility. Its interpretation relies on observing historical extremes and trends for the specific asset.
  • Over-Optimization: Trying to find "perfect" parameters for every asset can lead to overfitting and poor out-of-sample performance.
  • Not a Standalone Indicator: Chaikin Volatility is a valuable piece of the puzzle but should always be part of a comprehensive trading system, never used in isolation.
09

Conclusion

Conclusion

Chaikin Volatility is an insightful technical indicator available in Pinescript for TradingView that offers a unique way to measure market volatility and anticipate shifts in price behavior. By quantifying the spread between high and low prices, it helps traders identify periods of consolidation preceding strong breakouts, as well as potential trend exhaustion. While it does not provide directional signals, its ability to reveal the intensity of market participation is invaluable. By understanding its calculation, thoughtfully tuning its parameters, and integrating it strategically with directional indicators and robust price action analysis, you can leverage Chaikin Volatility to enhance your trading decisions and gain a clearer understanding of the market's underlying energy.

Enhance Your Trading

Get a high-performance Pinescript analysis tool for actionable market insights, designed for traders on the move.

This strategy runs in live mode on TradingView, helping you identify potential opportunities.

Get Pinescript Strategy