TradingView indicator guides

RCI Ribbon: Three Windows, One Rank Calculation

RCI Ribbon places three price-rank calculations on one oscillator scale. The copy below uses close and lookbacks of 10, 30 and 50 chart bars. Comparing their signs can reveal different price ordering across those windows, but the lines are neither independent confirmations nor three different chart timeframes.

Inspect the Pine Script

Rank each window separately

TradingView’s RCI Ribbon documentation describes three RCI calculations. Each correlates price ranks with chronological bar positions and scales the result by 100. Equal prices receive average ranks. Blue, red and green represent the short, middle and long windows.

The middle calculation does not smooth the short line. Each window sorts its own prices afresh. The single RCI guide explains the rank calculation in detail. A separate RCI with length 30 and the same source, history and chart context reproduces the red series; duplicating it does not add another source of evidence.

RCI(n) = 100 × correlation(time ranks, price ranks) No tied prices: RCI(n) = 100 × [1 − 6 × sum(d²) / (n × (n² − 1))]

The shortcut on the second line assumes no ties. With tied prices, use the correlation of average ranks rather than applying that shortcut unconditionally. If all prices in a window are equal, price-rank variance is zero and the mathematical correlation is undefined. The copy delegates calculation to ta.rci; it adds no separate flat-window, missing-data or startup policy.

A five-price check of three different windows

Use the synthetic closes 100, 101, 105, 104, 103, from oldest to newest. To keep every rank visible, use lengths 3, 4 and 5 for this arithmetic example, rather than the copy’s 10/30/50.

LengthWindowPrice ranks in time orderRCI
3105, 104, 1032, 1, 0−100
4101, 105, 104, 1030, 3, 2, 1+20
5100, 101, 105, 104, 1030, 1, 4, 3, 2+60

The final three prices decline strictly, while the five-price window retains positive rank correlation. Neither reading contradicts the other: they describe different observations. The final price also remains above the first price despite the negative short reading. No future price or trade outcome is implied.

Replacing each price x with 10x + 500 leaves every rank and every RCI unchanged. More generally, a strictly increasing transformation preserves ordering. This is why larger price swings alone cannot establish that an asset reaches RCI extremes more often. An outlier can still change the ranks of several observations; ranking does not make the indicator immune to abrupt changes.

Sign agreement is not strict line ordering

“All three above zero” and “short > middle > long > zero” are different conditions. The latter adds strict ordering. If prices rise strictly throughout all three windows, every RCI is +100: all signs agree, but the strict ordering test fails because the values are equal. The corresponding strictly falling sequence gives three −100 readings.

Consequently, a chosen ordering rule cannot be treated as a necessary definition of a strong trend. A longer lookback is not guaranteed to turn after a shorter one, and no fixed spacing ratio makes overlapping windows independent. Equal lengths with the same source produce equal lines; nearby lengths may differ as observations enter and leave their windows.

The ±80 levels and the shaded region are visual references. They are not price targets, confidence intervals, a measured normal range or proof of buying or selling exhaustion. A reading can remain at an extreme through many bars. A crossing between two RCI lines describes their relationship, not an automatic reversal of price.

Match the claims to this script

The helper calls ta.rci three times and returns the three results. Its arguments are hardcoded to close, 10, 30 and 50. The copy has no input declarations, alert conditions, orders, divergence detector or alignment flags. TradingView’s built-in indicator has an input interface; this minimal copy does not expose that interface.

All three calculations use the chart’s current timeframe. Fifty five-minute bars represent 250 minutes of bar duration when those bars are contiguous, or 4 hours 10 minutes. The first and last close timestamps are 49 bar intervals apart. Session breaks and missing bars can make elapsed clock time longer. Nothing here requests a daily or higher-timeframe series.

The current close can change before the bar closes, changing the ranks and plots. This code has no bar-close gate. An adaptation that issues alerts must explicitly choose whether to wait for confirmation and whether a condition should fire once on entry or on every bar while it remains true.

Specify and test a rule before judging it

To study sign agreement, define the exact condition, whether equality counts, and whether only the first agreeing bar is an event. For an ordering rule, include the all-100 and all-minus-100 examples above so strict equality behavior is intentional. For an extreme-level rule, define a touch, a strict crossing and any required return inside the band separately.

A trading test additionally needs entry timing, exits, costs and separate evaluation data. Changing 10/30/50 to another combination changes the hypothesis; it does not establish a better timeframe or win rate. This page provides no measured market performance, inventor attribution or universal parameter recommendation.

Pine Script v6: implementation and limits

The complete copy below retains the three built-in RCI calls and fixed plotting setup. It supplies no custom handling for flat windows and no alert or strategy logic.

Pine Script v6
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © Pineify

//@version=6
indicator(title="RCI Ribbon", overlay=false, max_labels_count=500)

// RCI Ribbon Calculation
p_ta_rci_ribbon(series float source, simple int shortLength, simple int middleLength, simple int longLength) =>
    shortRci = ta.rci(source, shortLength)
    middleRci = ta.rci(source, middleLength)
    longRci = ta.rci(source, longLength)
    [shortRci, middleRci, longRci]

[p_ind_1_shortRci, p_ind_1_middleRci, p_ind_1_longRci] = p_ta_rci_ribbon(close, 10, 30, 50)

// RCI Ribbon Plots
plot(p_ind_1_shortRci, "RCI Ribbon - Short RCI", color.rgb(33, 150, 243, 0), 1)
plot(p_ind_1_middleRci, "RCI Ribbon - Middle RCI", color.rgb(244, 67, 54, 0), 1)
plot(p_ind_1_longRci, "RCI Ribbon - Long RCI", color.rgb(76, 175, 80, 0), 1)
hline(0, "RCI Ribbon - Middle Band", color=#787B86)
p_ind_1_shortRci_upper = hline(80, "RCI Ribbon - Upper Band", color=#787B86, linestyle=hline.style_dashed)
p_ind_1_shortRci_lower = hline(-80, "RCI Ribbon - Lower Band", color=#787B86, linestyle=hline.style_dashed)
fill(p_ind_1_shortRci_upper, p_ind_1_shortRci_lower, color=color.rgb(33, 150, 243, 90), title="RCI Ribbon - Background")
Existing indicator chart preview
Existing visual preview. Verify exact values against the source; the image is not a performance result.

Specify a checkable adaptation in Pineify

Ask the Pine Script AI Coding Agent to expose the three lengths as inputs or add a precisely defined event. Include tie handling, flat-window behavior, confirmation timing and the synthetic fixtures above. Validate the generated script and compare its per-bar values before adding trading assumptions.

Open Pine Script AI Coding Agent

Educational indicator analysis. No measured trading performance is established here. Syntax validation does not prove formula equivalence, execution assumptions or profitability.

Implementation questions

No. Each ta.rci call ranks a separate source window. The middle line is not an average of short-line values.

That strict ordering is an optional rule. All three lines can be +100 on a strictly rising sequence, so positive sign agreement can occur without strict ordering.

No. The copy calculates three lengths on the same chart timeframe. It has no higher-timeframe request.

This copy hardcodes close and lengths 10, 30 and 50. It has no input declarations. TradingView’s built-in version has configurable inputs; adding inputs to this copy requires a code change.

With matching source, history and chart context, it reproduces the same calculation. It provides another display of the same data, not independent confirmation.

It is a reference level for strong positive rank correlation. It does not establish exhaustion or the profitability of selling, and readings can remain above it.