TradingView indicator comparisons

RSI vs CCI on TradingView: scale, inputs and signal tests

RSI compares smoothed gains with smoothed losses on a 0 to 100 scale. CCI measures the current source value relative to its moving average, divided by mean absolute deviation and a scaling constant. Its readings can exceed ±100. Choose the measurement that matches your rule: directional changes for RSI, or distance from a recent average for CCI. On the identical prices below, CCI crosses below zero while RSI remains above 50; neither reading is a calculation error.

See the decision guide

The inputs, memory and scale are different

For RSI, split consecutive source changes into nonnegative gains and loss magnitudes. Let G and L be their Wilder-smoothed averages. RSI = 100 × G / (G + L) when the sum is positive. For CCI, let x be the selected source, M its N-bar simple average, and D the mean of |xᵢ − M| across those same N bars. CCI = (x − M) / (0.015 × D). D is mean absolute deviation around the current window mean, not standard deviation.

  • The TradingView CCI help page illustrates typical price in its formula but lists Close under Source. Select the source explicitly in Inputs rather than assuming a default. This page uses close for both indicators to isolate their calculations.
  • Both formulas are dimensionless. Multiplying all source values by a positive constant scales the numerators and denominators together, leaving both readings unchanged. That does not make their thresholds interchangeable.
PropertyRSICCI
MeasurementBalance of directional changes.Distance from the current window mean relative to dispersion.
MemoryEach new gain/loss gets weight 1/N; earlier history decays.Only the most recent N source values enter the mean and deviation.
Center50: G equals L, provided their sum is positive.0: current source equals its window mean, provided D is positive.
Common extreme referencesBelow 30 or above 70.Below −100 or above +100.
ScaleFixed range 0 to 100.No fixed ±100 cap; attainable range also depends on N.

What "unbounded CCI" does and does not mean

CCI is often described as unbounded because ±100 are not endpoints like RSI 0 and 100. There is a useful qualification: with a fixed N-bar window that includes the current value and D > 0, |CCI| cannot exceed N / 0.03. Deviations from the mean sum to zero, so their absolute sum is at least twice the magnitude of any one deviation. Substituting that inequality into the CCI formula gives this length-dependent bound.

  • For N = 5, the mathematical ceiling is 166.67. A window of 100, 100, 100, 100, 110 reaches it: M = 102, D = 3.2, and CCI = 8 / (0.015 × 3.2) = 166.67.
  • For N = 20, the ceiling is 666.67. This derivation assumes the stated mean-deviation formula, with no missing values. It is not a proposed trading threshold or a claim that prices follow a particular distribution.
  • RSI can equal 100 when gains are positive and losses are zero, or 0 in the reverse case. When G and L are both zero, the ratio needs an explicit handling rule. CCI also needs one when the entire source window is flat and D = 0.

One price sequence: reproduce both calculations

These are hypothetical closing prices, not market data or a backtest. Use length 5 and source close for both indicators, with no added smoothing line. Bars 0 through 5 close at 100, 101, 102, 103, 104, 105. Initialize RSI at bar 5 with the arithmetic means of those five changes: G = 1 and L = 0. Thereafter update each average as (4 × previous average + current gain or loss) / 5. CCI uses the latest five closes, including the current bar.

  • At bar 7, the CCI window is 103, 104, 105, 104, 103. Its absolute deviations from 103.8 sum to 3.2, so D = 0.64 and CCI = −0.8 / 0.0096 = −83.33. RSI has G = 0.64 and L = 0.36, giving 64.
  • At bar 8, a gain of 1 makes G = 0.712 and L = 0.288, so RSI = 71.20. The close equals the CCI mean, making CCI exactly zero. At bar 9, G = 0.9696 and L = 0.2304 give RSI = 80.80.
  • At bars 10 through 13, both RSI averages decay by 4/5 each bar, preserving their ratio. CCI changes as older prices leave its window. At bar 13 its denominator becomes zero; this table labels the mathematical result undefined rather than inventing a neutral value.
  • Values retain full precision before display rounding. This explicit RSI seed is part of the example. A chart with earlier price history can initialize differently; compare only after accounting for that history.
BarCloseCCI mean MDeviation DCCI (5)RSI (5)
5105103.001.20111.11100.00
6104103.600.8830.3080.00
7103103.800.64−83.3364.00
8104104.000.400.0071.20
9106104.400.88121.2180.80
10106104.601.1283.3380.80
11106105.001.2055.5680.80
12106105.600.6441.6780.80
13106106.000.00Undefined80.80

Run extreme-zone and center-line tests separately

Evaluate bars 6 through 12, using bar 5 as the preceding observation. Define an upward cross as previous value at or below the level and current value strictly above it. A downward cross requires previous value at or above the level and current value strictly below it. Equality alone is not a crossing. Exclude bar 13 from CCI events because its result is undefined.

  • At bar 8, CCI touches zero but does not cross strictly above it. Bar 9 qualifies because the previous value equals zero. Rounding an almost-zero value before testing could change this result; use the underlying number.
  • No lower-extreme event occurs in this sample. To check the symmetric cases, transform every price to 210 minus its original value. With the corresponding seed, RSI becomes 100 minus its original reading and CCI changes sign. The same event logic then tests 30 and −100.
  • These counts test definitions on a constructed series. They do not establish which indicator leads consistently, predicts reversals, or earns a higher return.
ExperimentRSI eventsCCI events
Leave an upper extreme downward: 70 / +100Bar 7Bars 6 and 10
Enter an upper extreme upward: 70 / +100Bar 8Bar 9
Cross center downward: 50 / 0NoneBar 7
Cross center upward: 50 / 0NoneBar 9

Where the apparent signal can fail

At bar 10, CCI leaves its upper extreme while price is unchanged at 106; the next three closes also remain 106. Treating that cross as proof of an immediate price decline fails in this example. RSI stays above 70 throughout that flat segment, so an upper-zone state does not mean price is rising on every bar either.

  • Persistent trends: for an indefinite sequence of +1 changes and length 5, RSI stays at 100 while CCI stays at 111.11 after initialization. Selling every high reading repeatedly opposes the assumed rising price path.
  • Small oscillations: a center-line cross can occur near the moving average without a durable trend change. At bar 7 CCI is negative even though RSI remains above 50; the two center lines test different conditions.
  • Input mismatch: changing high or low while keeping close unchanged changes typical price but not close-based RSI. A comparison using CCI typical price must disclose that extra input difference.
  • Missing or flat data: require valid current and previous values for an event. Do not replace undefined CCI with zero and accidentally manufacture a crossing.

Repeat the comparison on TradingView before adding trades

Add the built-in RSI and CCI to one standard candlestick chart in separate panes. Set both sources to close, explicitly record their lengths, and use the same exchange symbol, session, interval and evaluation dates. Inspect the same completed candle in the Data Window. Keep each indicator on the chart timeframe for the first test and hide extra moving-average overlays.

  • First compare matched lengths to inspect the formulas. Then, if useful, test RSI 14 and CCI 20 as a separately labeled settings comparison. Matching lengths does not match the memory of the indicators.
  • Provide earlier bars for RSI warm-up. Record event timestamps, values, threshold, direction and excluded invalid bars. Keep upper/lower-extreme events separate from center-line events.
  • For a trading test, define entries, exits, position sizing, fill timing, commission and slippage before testing. Keep these assumptions identical and reserve a later period that did not inform rule selection. A signal count is not a performance metric.

Write the selected rule as a script specification

The Pine Script AI Coding Agent can draft code from your stated rules. Supply the source, length, seed assumptions, exact crossing inequalities and invalid-value policy. Ask for separate RSI and CCI readings and an event log before adding strategy orders. Use the table above as a calculation fixture, then review the generated source, run syntax validation and check chart values.

  • Keep the extreme-zone and center-line experiments in separate modes. Combining both indicators is a third rule to evaluate; their agreement is not independent evidence because both transform price.
  • A syntax pass verifies code syntax, not whether the trading hypothesis is profitable or whether its data and execution assumptions are appropriate.
Where Pineify fits

Pine Script AI Coding Agent

Draft your RSI or CCI rule with named inputs and explicit crossing conditions. Review the source and validate its calculations before testing trades.

Draft an RSI/CCI comparison

Frequently asked questions

Educational comparison, not investment advice. The prices, calculations and events are hypothetical, not backtested or live returns. Neither indicator nor generated code guarantees profitable trades. Validate complete rules and execution assumptions independently.

Sources and verification

Published by Pineify. Pineify is an independent product and is not affiliated with TradingView. Sources support the technical explanations; examples do not establish trading performance.