1Copy the scriptPress Copy script above, or the copy button on the code below.
2Open the Pine EditorOpen a TradingView chart and choose Pine Editor at the bottom of the screen.
3Paste over the templateCreate a new indicator, select all of the template text and paste. Press Save and give it a name.
4Add it to the chartPress Add to chart, then adjust the settings with the gear icon next to its name.
Source Code
88 lines of Pine Script v6 from Capital41_Duo/Capital41_Duo.pine, published under MIT. Keep the author's credit and licence lines when you reuse it.
Capital41_Duo.pine
// Copyright (c) 2026 Capital41 | MIT License
// CAPITAL41 DUO (RSI + Williams %R)
//
// What it does:
// - Dual oscillator overlay: RSI (0-100) and Williams %R (standard -100 to 0).
// - Background turns dark green when both indicators are oversold,
// red when both are overbought, gray otherwise.
// - Two large blue badges show live RSI and W%R values.
// - Configurable alert when both oscillators enter oversold or overbought territory.
//
// TradingView setup:
// 1) Open TradingView -> Pine Editor.
// 2) Paste this script, Save, and Add to chart.
// 3) Use any timeframe on any liquid instrument.
// 4) Adjust oversold/overbought levels via inputs.
//
// Usage guide:
// - Dark green background = both RSI and W%R oversold (potential buy zone).
// - Red background = both RSI and W%R overbought (potential sell zone).
// - Gray background = mixed/neutral readings.
//@version=6
indicator("Capital41 Duo", overlay = true)
// Inputs
rsiLen = input.int(14, "RSI length", minval = 2)
wrLen = input.int(14, "Williams %R length", minval = 2)
rsiOS = input.float(25.0, "RSI oversold level", minval = 1.0, maxval = 50.0, step = 1.0)
rsiOB = input.float(78.0, "RSI overbought level", minval = 50.0, maxval = 99.0, step = 1.0)
wrOS = input.float(-92.0, "W%R oversold level", minval = -100.0, maxval = -50.0, step = 1.0)
wrOB = input.float(-8.0, "W%R overbought level", minval = -50.0, maxval = 0.0, step = 1.0)
requireTurn = input.bool(true, "Require turn confirmation")
showBg = input.bool(true, "Show background")
showBadge = input.bool(true, "Show status badge")
colorBull = color.new(color.green, 0)
colorBear = color.new(color.red, 0)
colorBadge = color.new(color.blue, 0)
colorNeutral = color.new(color.gray, 0)
// RSI (0-100)
rsi = ta.rsi(close, rsiLen)
// Williams %R standard (-100 to 0)
hh = ta.highest(high, wrLen)
ll = ta.lowest(low, wrLen)
wrRng = hh - ll
wr = wrRng == 0 ? -50.0 : (hh - close) / wrRng * -100
// Turn detection: was in zone on previous bar AND now ticking back
rsiTurnUp = rsi[1] < rsiOS and rsi > rsi[1]
wrTurnUp = wr[1] <= wrOS and wr > wr[1]
rsiTurnDown = rsi[1] > rsiOB and rsi < rsi[1]
wrTurnDown = wr[1] > wrOB and wr < wr[1]
// Zone classification
bothOversold = requireTurn ? (rsiTurnUp and wrTurnUp) : (rsi < rsiOS and wr <= wrOS)
bothOverbought = requireTurn ? (rsiTurnDown and wrTurnDown) : (rsi > rsiOB and wr > wrOB)
// Background (dark green for buy, red for sell, gray for neutral)
bgcolor(showBg ? (bothOversold ? color.new(colorBull, 75) : bothOverbought ? color.new(colorBear, 80) : color.new(colorNeutral, 92)) : na)
// Status badge (2 large blue boxes, white text)
var table status = table.new(position.bottom_left, 2, 1, border_width = 2)
if barstate.islast
if showBadge
rsiText = " RSI " + str.tostring(rsi, "#.0") + " "
wrText = " W%R " + str.tostring(wr, "#.0") + " "
table.cell(status, 0, 0, rsiText, bgcolor = color.new(colorBadge, 55), text_color = color.white, text_size = size.large)
table.cell(status, 1, 0, wrText, bgcolor = color.new(colorBadge, 55), text_color = color.white, text_size = size.large)
else
for i = 0 to 1
table.cell(status, i, 0, "", bgcolor = color.new(color.black, 100), text_color = color.new(color.black, 100))
// Alerts (non-repainting, configurable via oversold/overbought inputs)
alertcondition(bothOversold and barstate.isconfirmed, title = "Duo Oversold",
message = "Capital41 Duo: RSI < {{rsiOS}} + W%R < {{wrOS}} on {{ticker}} ({{interval}})")
alertcondition(bothOverbought and barstate.isconfirmed, title = "Duo Overbought",
message = "Capital41 Duo: RSI > {{rsiOB}} + W%R > {{wrOB}} on {{ticker}} ({{interval}})")
Overview
Capital41 Duo paints a dark green background when both are oversold and a red background when both are overbought, otherwise gray. With turn confirmation enabled, those states require a prior extreme and a tick back rather than a simple threshold cross. Lengths and overbought and oversold levels are adjustable. Optional badges show the latest RSI and Williams %R values. Alerts fire only after the bar is confirmed. It does not place trades or define exits.
The inputs you can change from the gear icon on the chart. Defaults are the author's.
Setting
Type
Default
Variable
RSI length
int
14
rsiLen
Williams %R length
int
14
wrLen
RSI oversold level
float
25.0
rsiOS
RSI overbought level
float
78.0
rsiOB
W%R oversold level
float
-92.0
wrOS
W%R overbought level
float
-8.0
wrOB
Require turn confirmation
bool
true
requireTurn
Show background
bool
true
showBg
Show status badge
bool
true
showBadge
Third-party code. ForexR did not write, test or endorse this script, and the summary above was generated automatically from its code and README. Indicators describe the past, and a strategy's backtest can look better than live trading, especially when a script repaints. Check it in the Strategy Tester and on a demo account before you rely on it.
The Adaptive RSI Moving Average (ARSIMA) is an overlay indicator that dynamically adjusts its smoothing factor based on the Relative Strength Index (RSI). When the RSI moves toward extreme overbought or oversold conditions, the smoothing factor increases to ma
This overlay indicator screens a pasted list of up to forty symbols and draws a table on the price chart. It classifies bullish or bearish setups from the percent change between the current candle and the candle 250 bars back, then shows RSI with a simple movi
This indicator plots trade entry and exit signals on the price chart by combining Bollinger Bands with optional filter conditions. It calculates standard Bollinger Bands along with RSI, Aroon, and moving average filters. Reversal signals trigger when price bre
This indicator plots three moving averages on the price chart alongside colored fills between the lines to visualize trend structure. Internally, it calculates a Stochastic RSI oscillator to detect oversold reversals. When the Stochastic %K line rises above 10
Mean Reversion Study is an indicator that identifies trade setups combining exponential moving averages, RSI extremes, and engulfing candlestick patterns. It highlights bullish setups when a bullish engulfing candle forms below the EMA while RSI is oversold, a
This overlay indicator marks call and put setups from EMAs, RSI, MACD, and a SPY volume ratio. A call needs higher highs, RSI above its minimum, rising MACD, above-average proxy volume, and a rising trend EMA; a put reverses those tests. Early markers use an E