Momentum

CCI Signals: Threshold Crosses and Divergence Limits

Interpret CCI threshold and zero-line crosses with a Pine Script example. Separate a two-bar comparison from confirmed swing divergence and avoid untested scores.

CCI Signal Interpretation

Quick-reference guide to 5 signal types you will see on the chart.

Signal TypeIndicator ConditionMarket MeaningInterpretation limits
Recovery above the lower thresholdCCI crosses above the selected negative levelThe oscillator leaves that low zone.Not proof that a price rebound will continue.
Retreat below the upper thresholdCCI crosses below the selected positive levelThe oscillator leaves that high zone.Not proof that an uptrend is over.
Expansion through an outer thresholdCCI crosses above the upper or below the lower levelAn extension away from the selected average-relative range.Trend and reversal interpretations conflict without a defined strategy.
Zero-line crossCCI changes sign around zeroSource changes sides of its lookback average when deviation is defined.Not a universal higher/lower quality signal.
Regular divergence conceptCorresponding price swings and CCI swings move in opposite directionsRequires a defined pivot and confirmation method.Not implemented by the threshold-only code below; two arbitrary bars are not confirmed swings.

CCI Pine Script Signal Code

Educational indicator example. Review its exact rules and compare its plots with your intended calculation in TradingView. It does not place orders or establish profitability.

Pine Script v6
//@version=6
indicator("CCI Threshold Condition Examples", overlay=false)
length = input.int(20, "CCI Period", minval=1)
source = input.source(close, "Source")
upper = input.float(100, "Upper Level", minval=0.1)
lower = input.float(-100, "Lower Level", maxval=-0.1)
cci = ta.cci(source, length)
recoveryCross = ta.crossover(cci, lower)
retreatCross = ta.crossunder(cci, upper)
upperCross = ta.crossover(cci, upper)
lowerCross = ta.crossunder(cci, lower)
zeroUpCross = ta.crossover(cci, 0)
zeroDownCross = ta.crossunder(cci, 0)
recovery = barstate.isconfirmed and recoveryCross
retreat = barstate.isconfirmed and retreatCross
extensionUp = barstate.isconfirmed and upperCross
extensionDown = barstate.isconfirmed and lowerCross
zeroUp = barstate.isconfirmed and zeroUpCross
zeroDown = barstate.isconfirmed and zeroDownCross
plot(cci, "CCI", color=color.blue)
hline(upper, "Selected upper level", color=color.red)
hline(lower, "Selected lower level", color=color.green)
hline(0, "Zero", color=color.gray)
plotshape(recovery, "Lower-zone recovery", shape.triangleup, location.bottom, color=color.green, size=size.small)
plotshape(retreat, "Upper-zone retreat", shape.triangledown, location.top, color=color.red, size=size.small)
plotshape(extensionUp, "Upper extension", shape.circle, location.top, color=color.aqua, size=size.tiny)
plotshape(extensionDown, "Lower extension", shape.circle, location.bottom, color=color.orange, size=size.tiny)
alertcondition(recovery, "CCI lower-zone recovery", "Confirmed CCI cross above the selected lower level")
alertcondition(retreat, "CCI upper-zone retreat", "Confirmed CCI cross below the selected upper level")
alertcondition(extensionUp, "CCI upper extension", "Confirmed CCI cross above the selected upper level")
alertcondition(extensionDown, "CCI lower extension", "Confirmed CCI cross below the selected lower level")
alertcondition(zeroUp, "CCI zero cross up", "Confirmed CCI cross above zero")
alertcondition(zeroDown, "CCI zero cross down", "Confirmed CCI cross below zero")

Example settings for CCI

Record the inputs used by the example. These settings are not an optimized trading recommendation.

Feature comparison table: Default vs Description
ParameterDefaultDescription
CCI Period20, exampleWindow for the average and mean absolute deviation. A different period defines a different rule; no lead-time improvement is measured here.
SourceCloseMatches this example. The traditional formula is often described using typical price; record the selected source when comparing implementations.
Upper Level100, examplePositive reference level, not a calibrated probability of overvaluation or reversal.
Lower Level-100, exampleNegative reference level. Widening the threshold changes the event set; it does not automatically improve outcomes.

Turn the condition into an explicit rule

Specify the calculation, confirmation time, entry and exit rules before asking Pineify to draft or revise Pine Script. Review the code and simulate realistic costs before evaluating a strategy.

Explore Pine Script coding

FAQ

CCI Signals FAQ

Is CCI bounded like RSI?
No. CCI is an average-relative deviation oscillator with no fixed 0–100 bounds. Comparing threshold timing with RSI requires specific inputs and data, not a universal claim that CCI leads by several bars.
Does a two-bar disagreement count as confirmed divergence?
It only describes those two observations. A swing-divergence detector needs corresponding pivots, spacing and confirmation rules. This example deliberately emits threshold alerts only, so it cannot be mistaken for a validated divergence detector.
Can CCI change while the candle is open?
Yes. Its source and calculation can change on the developing bar. These events require a completed bar. That does not certify every custom CCI variant or higher-timeframe implementation as non-repainting.
Are +100 and -100 reliable buy/sell levels?
They are conventional references. A strong trend can remain beyond them. No numeric reliability, personal trade sample or profitable strategy is established here.
How can I check the example?
Match its source and length with the built-in CCI. Inspect the exact crossing bar for each alert, then test notification delivery separately. A performance study also needs exits, sizing, costs and later data.