Relative Strength Cloud compares a stock with its index directly on the price chart. The index is redrawn on the stock’s own scale: the grey line is the price the stock would have if it had moved exactly like the index since the start of the period. The space between the price and that line is filled with a cloud, green when the stock is ahead of its index and red when it is behind. Both start level again at each new period, every finished period is stamped with its score, dots mark the new highs and lows of the stock / index ratio, and a table compares the two over several horizons.
This code is written in ProRealCode Script and runs with ProRealCode Studio on ProRealTime Web.

Siemens, daily candles, against the DAX, restarted every year. 2024 ended 7.5 % behind the index (red label) and 2025 ended 3.6 % ahead (green label). In 2026 the stock dropped under the DAX path in March and April, moved back above it in May and has stayed there: 6.1 % ahead for the year to date.
Relative strength is usually a line in a separate panel: the price of the stock divided by the price of the index. The line says whether the stock does better or worse than the market, but it has no unit you can trade with, and you have to look away from the price to read it.
Here the same information is put where the price is. The question “is this stock stronger than its index?” becomes “is the price above or below the grey line?”, and the answer has a size: the height of the cloud is the number of euros, dollars or points the stock has gained or lost against its index since the period began.
The index is read candle by candle with MarketData, on the timeframe of the chart. At the start of each period, the code keeps the last close of the stock and the last close of the index. From there, the grey line is the stock’s starting price multiplied by the performance of the index. If the index has gained 2 % since the start of the period, the line sits 2 % above the stock’s starting price, whatever the stock did.
A stock can rise and still be below its line: the index simply rose more. That is the case a price chart alone does not show.
The cloud fills the gap between the price and the index path. It is green when the stock leads and red when it lags. It is dense along the index path and fades towards the price, so the candles stay readable.
The comparison restarts at each new period: a day, a week, a month, a quarter or a year. A dotted vertical line marks the restart, and the path leaves again from the price. When a period ends, a label gives its score: the performance of the stock minus the performance of the index over that period. A green label above the candle is a period won by the stock, a red label under it a period lost. The first period of the chart is incomplete and gets no score.
On the last candle, a label on the cloud gives the score of the period in progress.

Volkswagen, 15 minutes, against the DAX, restarted every month. In November the stock traded around 5 euros under the DAX path, then caught up in the last sessions and finished the month level with the index (+0.1 %). December starts the other way: after four sessions the stock is 8.2 % behind, with a run of red dots as the ratio makes new lows.
Behind the cloud, the code also keeps the classic relative strength line: the price of the stock divided by the price of the index. This ratio does not restart with the periods. It is compared with its own average over 50 candles, which gives four regimes:
The dots mark the candles where the ratio makes its highest or its lowest value of the last 120 candles. Only the first candle of a run is marked.

Allianz, 5 minutes, against the DAX, restarted every day. Each session has its own cloud and its own score: +1 %, -1.1 %, 0 % and -1.6 % for the last four, and +1.4 % so far today. The table counts 18 sessions won out of 28, and the regime is Leading.
Paste the code into a new Studio tab and run it on the chart of a stock. The benchmark is the DAX by default, so start with a stock of that index. Every setting has a help text in the Settings form:

The settings form, in three sections: the benchmark, the relative strength and the display.
Three things to know before reading the chart:
A typical reading: the index falls for several sessions and a stock stays above its path, with a green cloud that widens and a ringed green dot under the candles. That stock is being bought while the market is sold, and it is often among the first to rise when the index turns. The mirror reading is a stock whose cloud is red period after period: it is a rally to distrust. Each of these is a reason. None of them is a signal on its own.
The code also shows several additions of ProRealCode Script: MarketData to read another instrument from the chart, input() settings of the instrument, list and switch types grouped in sections with their help texts, text variables joined with +, COLORBETWEEN with two colours for a cloud that fades from one edge to the other, DRAWLABEL for the scores, arrays for the rows of the table, and a table built with DRAWTABLE, TABLEMERGE, TABLECELL, TABLEBAR for the lead or lag bars and TABLESPARK for the shape of the ratio.
//----------------------------------------------------------------
// PRC_Relative Strength Cloud | indicator
// Author: Nicolas
// Date: 04.12.2026
// https://www.prorealcode.com
// License: CC BY-NC 4.0 - free to use, share and modify for
// non-commercial purposes, provided the author and the source
// above are credited.
// https://creativecommons.org/licenses/by-nc/4.0/
//----------------------------------------------------------------
// Relative strength of a stock against its index, drawn on the price.
// The index is read with MarketData and redrawn on the stock's own
// scale: the grey line is where the stock would be if it had moved
// like the index since the start of the period. The cloud between the
// price and that line is the stock's lead (green) or lag (red). Both
// start level again at each new period, and each finished period is
// stamped with its score. Dots mark the new highs and lows of the
// stock / index ratio, and a table compares the two over several
// horizons.
// Runs with ProRealCode Studio: https://www.prorealcode.com/prorealcode-studio/
//----------------------------------------------------------------
DEFPARAM overlay = true
input(bench, "DAX", "Benchmark index", instrument, group = "Benchmark", tooltip = "The index the chart is compared with, by its ProRealTime ticker. Put the chart on a stock of that index.")
input(anchor, "Month", "Restart the comparison every", string, options = ["Day", "Week", "Month", "Quarter", "Year"], group = "Benchmark", tooltip = "The stock and the index start level again at the beginning of each period. Day and Week suit intraday charts, Month to Year suit daily charts.")
input(rsLen, 50, "Trend of the relative strength (candles)", int, minval = 5, group = "Relative strength", tooltip = "The stock / index ratio is compared with its own average over this many candles: above it the stock is stronger than usual against the index, below it weaker.")
input(hiLen, 120, "New high or low over (candles)", int, minval = 10, group = "Relative strength", tooltip = "A dot is drawn when the stock / index ratio makes its highest or lowest value over this many candles.")
input(showDots, 1, "Dots on the new highs and lows", bool, group = "Display", tooltip = "Green under the candle: the ratio makes a new high. Red above it: a new low. A white ring means the ratio got there before the price did.")
input(showScores, 1, "Score of each finished period", bool, group = "Display", tooltip = "At the end of each period, a label gives the stock's performance minus the index's, in points of percent.")
input(showTable, 1, "Summary table", bool, group = "Display", tooltip = "The performance of the chart and of the index over the current period and four horizons, the regime of the relative strength and the shape of the ratio.")
// -- 1. The index, on the chart's timeframe ---------------------------
// MarketData reads another instrument candle by candle. Until its
// history has arrived it reads undefined, and nothing is drawn.
idx = MarketData(bench, default, close, default)
ready = 0
IF ISSET(idx) THEN
IF idx > 0 THEN
ready = 1
ENDIF
ENDIF
bName = bench
IF bench = "" THEN
bName = "the chart"
ENDIF
// The index path is a mid grey: it reads on a dark and on a light chart
pr = 120
pg = 128
pb = 142
// -- 2. A new period: the stock and the index start level again -------
newPeriod = 0
IF barindex > 0 THEN
IF anchor = "Day" THEN
newPeriod = Date <> Date[1]
ELSIF anchor = "Week" THEN
newPeriod = DayOfWeek < DayOfWeek[1]
ELSIF anchor = "Quarter" THEN
newPeriod = FLOOR((Month - 1) / 3) <> FLOOR((Month[1] - 1) / 3)
ELSIF anchor = "Year" THEN
newPeriod = Year <> Year[1]
ELSE
newPeriod = Month <> Month[1]
ENDIF
ENDIF
atr = AverageTrueRange[20](close)
once started = 0
once whole = 0
once flip = 0
once nPer = 0
once nWin = 0
IF ready AND (started = 0 OR newPeriod) THEN
IF started THEN
// The score of the period that just ended: stock minus index.
// The first period of the chart is incomplete and is not scored.
IF whole THEN
sc = (close[1] / a0 - idx[1] / i0) * 100
scTxt = ROUND(sc * 10) / 10
nPer = nPer + 1
IF sc > 0 THEN
nWin = nWin + 1
ENDIF
IF showScores THEN
IF sc >= 0 THEN
DRAWLABEL(barindex - 1, high[1] + 0.5 * atr, "+#scTxt# %", arrowdown, small) COLOURED(14, 18, 30) FILLCOLOR(60, 210, 150) BORDERCOLOR(60, 210, 150)
ELSE
DRAWLABEL(barindex - 1, low[1] - 0.5 * atr, "#scTxt# %", arrowup, small) COLOURED(255, 255, 255) FILLCOLOR(240, 85, 95) BORDERCOLOR(240, 85, 95)
ENDIF
ENDIF
ENDIF
whole = 1
// Both are measured from the last close of the period before
a0 = close[1]
i0 = idx[1]
DRAWVLINE(barindex) COLOURED(pr, pg, pb, 70) STYLE(dottedline, 1)
DRAWSEGMENT(barindex - 1, close[1], barindex, a0 * idx / i0) COLOURED(pr, pg, pb) STYLE(line, 2)
ELSE
a0 = close
i0 = idx
ENDIF
started = 1
flip = 1 - flip
ENDIF
// -- 3. The index path and the cloud ----------------------------------
// path: where the stock would be if it had moved like the index since
// the start of the period. Two curves take the periods in turn, so the
// line and the cloud break cleanly where a period ends.
path = undefined
gap = undefined
pathA = undefined
pathB = undefined
IF ready AND started THEN
path = a0 * idx / i0
gap = (close / a0 - idx / i0) * 100
IF flip THEN
pathA = path
ELSE
pathB = path
ENDIF
// The cloud is dense on the index path and fades towards the price
IF close >= path THEN
COLORBETWEEN(pathA, close, "#3cd29680", "#3cd2960a")
COLORBETWEEN(pathB, close, "#3cd29680", "#3cd2960a")
ELSE
COLORBETWEEN(pathA, close, "#f0555f80", "#f0555f0a")
COLORBETWEEN(pathB, close, "#f0555f80", "#f0555f0a")
ENDIF
ENDIF
// -- 4. The relative strength line: stock / index ---------------------
// It does not restart with the periods. Its regime compares it with
// its own average: above or below, and moving away or coming back.
ratio = undefined
IF ready THEN
ratio = close / idx
ENDIF
rsAvg = Average[rsLen](ratio)
lvl = (ratio / rsAvg - 1) * 100
momLen = MAX(1, ROUND(rsLen / 5))
mom = lvl - lvl[momLen]
regime = 0
IF ISSET(mom) THEN
IF lvl > 0 AND mom >= 0 THEN
regime = 1
ELSIF lvl > 0 THEN
regime = 2
ELSIF mom < 0 THEN
regime = 3
ELSE
regime = 4
ENDIF
ENDIF
// A dot when the ratio makes a new high or a new low. The white ring:
// the ratio got there while the price had not, it leads the price.
IF showDots AND ISSET(ratio[hiLen]) THEN
rsHi = Highest[hiLen](ratio)
rsLo = Lowest[hiLen](ratio)
IF ratio >= rsHi AND ratio[1] < rsHi[1] THEN
IF high < Highest[hiLen](high) THEN
DRAWPOINT(barindex, low - 0.6 * atr, 4) COLOURED(60, 210, 150, 235) BORDERCOLOR(255, 255, 255)
ELSE
DRAWPOINT(barindex, low - 0.6 * atr, 3) COLOURED(60, 210, 150, 200) BORDERCOLOR(14, 18, 30)
ENDIF
ENDIF
IF ratio <= rsLo AND ratio[1] > rsLo[1] THEN
IF low > Lowest[hiLen](low) THEN
DRAWPOINT(barindex, high + 0.6 * atr, 4) COLOURED(240, 85, 95, 235) BORDERCOLOR(255, 255, 255)
ELSE
DRAWPOINT(barindex, high + 0.6 * atr, 3) COLOURED(240, 85, 95, 200) BORDERCOLOR(14, 18, 30)
ENDIF
ENDIF
ENDIF
IF islastbarupdate THEN
IF ready = 0 THEN
// -- The index has not arrived, or its ticker is not known ----
wait = DRAWTABLE(2, 1, topleft) FILLCOLOR(42, 45, 52, 245) BORDERCOLOR(84, 90, 102)
TABLECELL(wait, 0, 0, "Relative strength · waiting for " + bName, bold, center, 13) COLOURED(250, 195, 80)
TABLECELL(wait, 1, 0, "If it stays, the ticker is not known: the status line of the editor names the nearest ones.", center) COLOURED(168, 175, 188)
ELSE
// -- 5. The lead or the lag of the current period, on the cloud
pTxt = anchor + " to date"
gTxt = ROUND(gap * 10) / 10
IF gap >= 0 THEN
DRAWLABEL(barindex + 1, (close + path) / 2, pTxt + ": +" + gTxt + " % vs " + bName, arrowleft, small) COLOURED(14, 18, 30) FILLCOLOR(60, 210, 150) BORDERCOLOR(60, 210, 150)
ELSE
DRAWLABEL(barindex + 1, (close + path) / 2, pTxt + ": " + gTxt + " % vs " + bName, arrowleft, small) COLOURED(255, 255, 255) FILLCOLOR(240, 85, 95) BORDERCOLOR(240, 85, 95)
ENDIF
// -- 6. The table ---------------------------------------------
// A neutral grey card with its own text colours: it reads the
// same on a dark and on a light chart.
IF showTable THEN
// Row 0 of the figures is the current period, then four horizons
$hz[0] = 0
$hz[1] = 20
$hz[2] = 60
$hz[3] = 120
$hz[4] = 250
$ok[0] = 1
$ps[0] = (close / a0 - 1) * 100
$pi[0] = (idx / i0 - 1) * 100
span = MAX(1, ABS(gap))
FOR i = 1 TO 4 DO
n = $hz[i]
$ok[i] = 0
IF barindex >= n THEN
IF ISSET(idx[n]) THEN
$ok[i] = 1
$ps[i] = (close / close[n] - 1) * 100
$pi[i] = (idx / idx[n] - 1) * 100
span = MAX(span, ABS($ps[i] - $pi[i]))
ENDIF
ENDIF
NEXT
board = DRAWTABLE(10, 4, topleft) FILLCOLOR(42, 45, 52, 245) BORDERCOLOR(84, 90, 102)
TABLEMERGE(board, 0, 0, 1, 4)
TABLECELL(board, 0, 0, "Relative strength vs " + bName, bold, center, 14) COLOURED(238, 240, 244)
TABLECELL(board, 1, 1, "Chart", bold, right) COLOURED(168, 175, 188)
TABLECELL(board, 1, 2, bName, bold, right) COLOURED(168, 175, 188)
TABLECELL(board, 1, 3, "Lead or lag", bold, center) COLOURED(168, 175, 188)
FOR i = 0 TO 4 DO
r = i + 2
IF i = 0 THEN
TABLECELL(board, r, 0, pTxt) COLOURED(238, 240, 244)
ELSE
n = $hz[i]
TABLECELL(board, r, 0, "#n# candles") COLOURED(168, 175, 188)
ENDIF
IF $ok[i] THEN
sTxt = ROUND($ps[i] * 10) / 10
iTxt = ROUND($pi[i] * 10) / 10
d = $ps[i] - $pi[i]
dTxt = ROUND(d * 10) / 10
IF $ps[i] >= 0 THEN
TABLECELL(board, r, 1, "#sTxt# %", right) COLOURED(70, 215, 155)
ELSE
TABLECELL(board, r, 1, "#sTxt# %", right) COLOURED(255, 110, 120)
ENDIF
IF $pi[i] >= 0 THEN
TABLECELL(board, r, 2, "#iTxt# %", right) COLOURED(70, 215, 155)
ELSE
TABLECELL(board, r, 2, "#iTxt# %", right) COLOURED(255, 110, 120)
ENDIF
// The middle of the bar is zero: a lead fills past it
IF d >= 0 THEN
TABLEBAR(board, r, 3, d, 0 - span, span, "+#dTxt# %") COLOURED(70, 215, 155)
ELSE
TABLEBAR(board, r, 3, d, 0 - span, span, "#dTxt# %") COLOURED(255, 110, 120)
ENDIF
ELSE
TABLECELL(board, r, 1, "-", right) COLOURED(168, 175, 188)
TABLECELL(board, r, 2, "-", right) COLOURED(168, 175, 188)
TABLECELL(board, r, 3, "not enough history", center) COLOURED(168, 175, 188)
ENDIF
NEXT
TABLECELL(board, 7, 0, "Regime") COLOURED(168, 175, 188)
TABLEMERGE(board, 7, 1, 1, 3)
TABLECELL(board, 8, 0, "Stock / index ratio") COLOURED(168, 175, 188)
TABLEMERGE(board, 8, 1, 1, 3)
IF regime = 1 THEN
TABLECELL(board, 7, 1, "Leading · above its trend and gaining", bold, right) COLOURED(70, 215, 155)
TABLESPARK(board, 8, 1, ratio, hiLen) COLOURED(70, 215, 155)
ELSIF regime = 2 THEN
TABLECELL(board, 7, 1, "Weakening · above its trend, coming back", bold, right) COLOURED(250, 195, 80)
TABLESPARK(board, 8, 1, ratio, hiLen) COLOURED(250, 195, 80)
ELSIF regime = 3 THEN
TABLECELL(board, 7, 1, "Lagging · below its trend and losing", bold, right) COLOURED(255, 110, 120)
TABLESPARK(board, 8, 1, ratio, hiLen) COLOURED(255, 110, 120)
ELSIF regime = 4 THEN
TABLECELL(board, 7, 1, "Improving · below its trend, coming back", bold, right) COLOURED(110, 170, 255)
TABLESPARK(board, 8, 1, ratio, hiLen) COLOURED(110, 170, 255)
ELSE
TABLECELL(board, 7, 1, "not enough history", right) COLOURED(168, 175, 188)
TABLESPARK(board, 8, 1, ratio, hiLen) COLOURED(168, 175, 188)
ENDIF
TABLECELL(board, 9, 0, "Finished periods ahead") COLOURED(168, 175, 188)
TABLEMERGE(board, 9, 1, 1, 3)
IF nPer > 0 THEN
TABLECELL(board, 9, 1, "#nWin# of #nPer#", right) COLOURED(238, 240, 244)
ELSE
TABLECELL(board, 9, 1, "none finished yet", right) COLOURED(168, 175, 188)
ENDIF
ENDIF
ENDIF
ENDIF
RETURN pathA COLOURED(pr, pg, pb) STYLE(line, 2) AS "Index path", pathB COLOURED(pr, pg, pb) STYLE(line, 2) AS "Index path (alternate periods)"