Indicator · Pine Script v6 · On the chart

Capital41 Duo

by damianpitt· code credited to Capital41 | MIT License

Capital41 Duo overlays RSI and Williams %R on the price chart and flags agreement between them.

View on GitHub

GitHub stars6on the repository
Pine versionv6current
Lines of code88
Settings9inputs
LicenceMIT
Last update2 months ago31 Aug 2026

Add It to Your TradingView Chart

  1. 1Copy the scriptPress Copy script above, or the copy button on the code below.
  2. 2Open the Pine EditorOpen a TradingView chart and choose Pine Editor at the bottom of the screen.
  3. 3Paste over the templateCreate a new indicator, select all of the template text and paste. Press Save and give it a name.
  4. 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.

Details

Published by

damianpitt on GitHub

Code credit

Capital41 | MIT License, as written in the script's header

Draws

On the price chart

Markets

Any symbol

Timeframes

Any timeframe

Risk Notes

No repainting, lookahead or stacked entries were found in its code or README. That says nothing about how well it works: test it first.

Topics

cryptoindicatorsmarket-structureorder-blockspinescriptsmart-moneytechnical-analysistechnical-analysis-indicatorstradingtradingview

Settings

The inputs you can change from the gear icon on the chart. Defaults are the author's.

SettingTypeDefaultVariable
RSI lengthint14rsiLen
Williams %R lengthint14wrLen
RSI oversold levelfloat25.0rsiOS
RSI overbought levelfloat78.0rsiOB
W%R oversold levelfloat-92.0wrOS
W%R overbought levelfloat-8.0wrOB
Require turn confirmationbooltruerequireTurn
Show backgroundbooltrueshowBg
Show status badgebooltrueshowBadge
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.

Similar Pine Scripts

947 stars

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

Indicator v4 Moving averagesOscillators & momentum
Updated 12 days ago · GPL-3.0 GitHub repository of Adaptive RSI Moving Average

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

Indicator v5 Oscillators & momentumVolume
Updated 1 year ago · MPL-2.0 GitHub repository of Momentum Setup - Ankush Bajaj Momentum Investing Setup

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

Indicator v4 Volatility & bandsOscillators & momentum
Updated 2 months ago · None stated GitHub repository of Bollinger Bands Winner IND [Alorse]
318 stars

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

Indicator v5 Moving averagesOscillators & momentum
Updated 2 months ago · MIT GitHub repository of TVT 3X Scale In Out
285 stars

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

Indicator v4 Mean reversionCandlestick patterns
Updated 3 years ago · None stated GitHub repository of Mean Reversion Study

More Oscillators & momentum scripts

Related on ForexR

Trade Your Charts With a Regulated Broker

Compare brokers that connect to TradingView, with spreads, minimum deposits and leverage side by side.

Compare brokers