Indicator · Pine Script v6 · Own pane

RedK DualTF Volume-Accelerated RSI

by theonetrade· code credited to RedKTrader

The RedK DualTF Volume-Accelerated RSI is a momentum indicator plotted in a separate pane.

View on GitHub

GitHub stars34on the repository
Pine versionv6current
Lines of code266
Settings17inputs
LicenceMIT
Last update2 weeks ago8 Nov 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

266 lines of Pine Script v6 from assets/indicator/bit-exact/redk_dualtf_volume_accelerated_rsi_redk_varsi_BKy9A1Ii.pine, published under MIT. Keep the author's credit and licence lines when you reuse it.

redk_dualtf_volume_accelerated_rsi_redk_varsi_BKy9A1Ii.pine
// This Pine Script® code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © RedKTrader
// Internal Build version : 1.40
//
//@version = 6
indicator("RedK DualTF Volume-Accelerated RSI", shorttitle = 'RedK_VARSI v1.2', overlay = false, precision = 1)

// =====================================================================================================
//  RedK VARSI (Volume-Accelerated RSI)
//  A reworked Pine v6 successor to the 2020 "RedK Vol_Weighted RSI", 
//  with a request.security() - based higher-timeframe ("Context") calculation, 
//  optional smoothing, a signal line, Dual TF alignment markers, and introduces 5 alerts.
// v1.1 fixes how VARSI for the closed bar in the Context timeframe is calculated to ensure accuracy - no repaint
// v1.2 an even better approach used to solve for the historic bars that matches TV's own approach - no repaint
// =====================================================================================================


// *****************************************************************************************************
//  Selectable moving-average type
// -----------------------------------------------------------------------------------------------------
f_getMA(_data, _len, MAtype) =>
    value = switch MAtype
        'SMA' => ta.sma(_data, _len)
        'EMA' => ta.ema(_data, _len)
        'HMA' => ta.hma(_data, _len)
        'RMA' => ta.rma(_data, _len)
        => ta.wma(_data, _len)
    value

// *****************************************************************************************************
//  Volume-Weighted RSI, using the selected MA method
//  Note: change() and volume are both read in whatever context this runs in (chart or security),
//  so when called inside request.security() it correctly uses the HTF close-change and HTF volume.
// -----------------------------------------------------------------------------------------------------
f_CalcVW_Rsi(int _len, string avg_type, bool _volWeighted) =>
    _vol   = na(volume) or not _volWeighted ? 1.0 : volume
    chg    = ta.change(close) * _vol
    up     = f_getMA(math.max(chg, 0), _len, avg_type)
    down   = f_getMA(-math.min(chg, 0), _len, avg_type)
    rsiraw = down == 0 ? 100 : up == 0 ? 0 : 100 - (100 / (1 + up / down))
    rsiraw


// -----------------------------------------------------------------------------------------------------
//   Inputs
// -----------------------------------------------------------------------------------------------------
grpC   = "Current Timeframe RSI"
grpH   = "Context Timeframe RSI"
grpsig = "Signal Line"
grplvl = "Levels"
disnon = display.none

// --- Current TF -------------------------------------------------------------------------------------
rsiLen   = input.int(14, minval = 1, title = "RSI Length", inline = "rsi", group = grpC)
avg_type = input.string('RMA', title = "Averaging", options = ['EMA', 'HMA', 'RMA', 'SMA', 'WMA'],
  inline = "rsi", group = grpC,
  tooltip = "Averaging method for the current-TF RSI.\nRMA reproduces Wilder's classic RSI." +
            "\nSet Length=14, Averaging=RMA, Smoothing=1, Volume Weighted=off to exactly match a standard RSI.")

VolWeighted = input.bool(true, "Volume Weighted", group = grpC,
  tooltip = '''When on, each bar's price change is weighted by that bar's volume before averaging. This
  emphasises moves that happen on higher participation.
  \nTurn off for a pure price-based RSI.''')

smooth    = input.int(3, minval = 1, title = "Smoothing", inline = "smooth", group = grpC, display = disnon)
smth_type = input.string('WMA', title = "Averaging", options = ['EMA', 'HMA', 'RMA', 'SMA', 'WMA'], display = disnon,
  inline = "smooth", group = grpC, active = smooth > 1,
  tooltip = "Optional smoothing to apply to Current TF RSI." +
            "\nHelps remove noise but introduces lag. Keep to small values or disable.")

col_rsi_long  = input.color(color.aqua, title = "Bullish", inline = "rsi_c", group = grpC)
col_rsi_short = input.color(#f57f17,     title = "Bearish", inline = "rsi_c", group = grpC)

// --- Signal line ------------------------------------------------------------------------------------
signal_len   = input.int(5, "Length", minval = 1, inline = "sig", group = grpsig, display = disnon)
sig_avg_type = input.string('EMA', title = "  Averaging", options = ['EMA', 'HMA', 'RMA', 'SMA', 'WMA'], display = disnon,
  inline = "sig", group = grpsig, active = signal_len > 1,
  tooltip = "Length and Averaging method for the RSI Signal Line.")
col_signal   = input.color(color.blue, title = "Signal Line Color", active = signal_len > 1,
  inline = "sig_c", group = grpsig)

// --- Context (Higher) TF ----------------------------------------------------------------------------
show_htf = input.bool(true, "Show Context RSI", group = grpH, display = disnon,
  tooltip = "Disabling this turns VARSI into a single TF volume-weighted RSI, and hides the Context TF Plot.\n" +
            "Also turns off the Alignment Markers & related alerts.")
htf_mult   = input.int(5, "Context Multiplier (× chart TF)", minval = 2, maxval = 60, group = grpH, 
  display = disnon, active = show_htf,
  tooltip = "Context TF = this many times the current chart timeframe. e.g. 5 on a 1H chart ≈ 5H")
            
htf_update = input.string('Live Update', "Context Update", options = ['Live Update', 'Last Closed Bar'], group = grpH, 
  display = disnon, active = show_htf,
  tooltip = "Live Update (default): the Context RSI updates as the higher-TF bar develops — most responsive. " +
            "Last Closed Bar: the Context RSI only changes when the higher-TF bar closes — steadier, no intrabar movement. " +
            "Has no effect when the Context TF equals the chart TF.")

col_rsiH_long  = input.color(#33aa00, title = "Bullish", inline = "htf_c", group = grpH, active = show_htf)
col_rsiH_short = input.color(#ff1111, title = "Bearish", inline = "htf_c", group = grpH, active = show_htf)

// --- Levels -----------------------------------------------------------------------------------------
show_align = input.bool(true, "Show Alignment Markers", group = grplvl, active = show_htf,
  tooltip = "Plot a marker when the Current TF RSI and the Context RSI agree on direction (both above / both below 50).")


// =====================================================================================================
//   Calculations
// -----------------------------------------------------------------------------------------------------
midline  = 50
ob_level = 70   
os_level = 30   

// Current TF VW-RSI + optional smoothing
rsiCTF_raw = f_CalcVW_Rsi(rsiLen, avg_type, VolWeighted)
rsiCTF     = smooth > 1 ? f_getMA(rsiCTF_raw, smooth, smth_type) : rsiCTF_raw

// Signal line
rsi_sig = signal_len > 1 ? f_getMA(rsiCTF, signal_len, sig_avg_type) : rsiCTF

// Resolve Context TF via the built-in (multiplier method)
htf_tf = timeframe.from_seconds(int(timeframe.in_seconds(timeframe.period) * htf_mult))

// Context TF must be >= chart TF. With minval=2 on the multiplier this is effectively always true,
// a lower resolved TF can never plot a misleading faster-than-chart backdrop.
htf_secs    = timeframe.in_seconds(htf_tf)
chart_secs  = timeframe.in_seconds(timeframe.period)

// Common flags
htf_invalid     = htf_secs < chart_secs
htf_is_higher   = htf_secs > chart_secs
use_last_closed = htf_update == 'Last Closed Bar' and htf_is_higher

// Pull the Context VW-RSI
// Get live HTF value (updates intrabar on the forming HTF bar)
rsiHi_live = request.security(syminfo.tickerid, htf_tf,
     f_CalcVW_Rsi(rsiLen, avg_type, VolWeighted),
     lookahead = barmerge.lookahead_off)

// *****************************************************************************************************
// Solving for the historical bar while providing the option to use last confirmed bar 
// to avoid the perception of a repaint.
// *****************************************************************************************************

// * Option (1) : The common mishandling of the HTF Series and its context
// This will bug out - shifts values back by one bar of chart's TF --- fixed 

//rsiHi = (htf_invalid or not show_htf) ? na : (use_last_closed ? rsiHi_raw[1] : rsiHi_raw)

// *****************************************************************************************************
// * Option (2) : the common approach - testing it for confirming the best option
// it will shift if compared against TV's own RSI by 1 bar of chart TF - but that's by design
// might be confusing to some users

// Get last CLOSED HTF value — offset INSIDE security. [1] + lookahead_on is the standard
// gap-free non-repaint pattern: the forward-peek is cancelled by the one-bar back-reference.
// Never drop the [1] with lookahead_on, or it WILL leak future data.

// rsiHi_closed = request.security(syminfo.tickerid, htf_tf,
//      f_CalcVW_Rsi(rsiLen, avg_type, VolWeighted)[1],
//      lookahead = barmerge.lookahead_on)

// *****************************************************************************************************
// * Option (3): This is another approach - could be the best option
// Last Closed Bar matches TradingView's "Wait for timeframe closes" 
// We basically re-use the same Request.security() call and move it to past value
// this approach will override barmerge.gaps_on - we're manually filling those gaps

// This chart bar is the last bar of the HTF bar when both close at the same time.
htf_bar_closes = time_close == time_close(htf_tf)
var float rsiHi_closed = na

// Capture the HTF value only then, and only after the chart bar is confirmed; 
// hold that value until the next HTF close. This also saves a request.security() call
if htf_bar_closes and barstate.isconfirmed 
    rsiHi_closed := rsiHi_live

// *****************************************************************************************************
// Any of the above approaches will lead here to resolve the final HTF value

// The confirmed-bar offset is only meaningful when the Context TF is higher than the chart TF;
// equal/lower uses the live value (avoids a pointless one-bar lag).
rsiHi = (htf_invalid or not show_htf) ? na : (use_last_closed ? rsiHi_closed : rsiHi_live)



// Direction / alignment state (alignment requires a valid, shown Context)
ctf_up   = rsiCTF > midline
htf_up   = rsiHi  > midline
aligned_up   = show_htf and not htf_invalid and ctf_up  and htf_up
aligned_down = show_htf and not htf_invalid and (not ctf_up) and (not htf_up)


// =====================================================================================================
//   Plots
// -----------------------------------------------------------------------------------------------------
// Levels first so z-order keeps the main line on top

dw          = display.data_window
d_sl        = display.status_line
dsp_dp_dw   = display.pane + display.data_window
// if a higher TF is enabled, related plots will show in panel and data window, otherwise hide all
dsp_htf     = show_htf ? dsp_dp_dw + d_sl : disnon 
dsp_htf_am  = show_htf ? dsp_dp_dw : disnon 

hline(midline,  title = "Midline",     color = color.new(color.yellow, 50), linestyle = hline.style_dotted)
hline(ob_level, title = "Overbought",  color = color.new(color.green,  30), linestyle = hline.style_dashed)
hline(os_level, title = "Oversold",    color = color.new(color.red,    30), linestyle = hline.style_dashed)


p1 = plot(rsiCTF, title = "Current RSI", color = ctf_up ? col_rsi_long : col_rsi_short, linewidth = 3)

ps = plot(rsi_sig, title = "RSI Signal", color = col_signal, linewidth = 1, display = d_sl + dsp_dp_dw)

p2 = plot(rsiHi, title = "Higher TF RSI",
     color = htf_up ? col_rsiH_long : col_rsiH_short, linewidth = 1, display = dsp_htf)

pl_midline = plot(midline, "midline ref", color = color.new(color.white, 100),
     editable = false, display = display.none)

// Context sentiment fill (above / below midline)
fill(p2, pl_midline, top_value = 100, bottom_value = 50,
    top_color = color.new(col_rsiH_long, 20), bottom_color = color.new(col_rsiH_long, 90))
fill(pl_midline, p2, top_value = 50, bottom_value = 0,
    top_color = color.new(col_rsiH_short, 90), bottom_color = color.new(col_rsiH_short, 20))

//==========================================================================================================
// Alignment markers - note to hide them also in data window if no HTF is plotted
plotshape(show_align and aligned_up   and not aligned_up[1],   title = "Bull Alignment", 
  display = not show_align ? disnon : dsp_htf_am,
     style = shape.triangleup,   location = location.bottom, color = col_rsiH_long,  size = size.small)
plotshape(show_align and aligned_down and not aligned_down[1], title = "Bear Alignment", 
  display = not show_align ? disnon : dsp_htf_am,
     style = shape.triangledown, location = location.top,    color = col_rsiH_short, size = size.small)


// =====================================================================================================
//   Alerts — all based on the single (Current TF) VARSI line,
//      so they are independent of the Context setting. 
// -----------------------------------------------------------------------------------------------------

alertcondition(ta.crossover(rsiCTF, midline),  title = "VARSI crosses above midline (Bullish)",
  message = "{{ticker}} — VARSI crossed ABOVE the midline (bullish)")
alertcondition(ta.crossunder(rsiCTF, midline), title = "VARSI crosses below midline (Bearish)",
  message = "{{ticker}} — VARSI crossed BELOW the midline (bearish)")
alertcondition(ta.cross(rsiCTF, midline),      title = "VARSI swings around midline (Up or Down)",
  message = "{{ticker}} — VARSI crossed the midline")

alertcondition(ta.crossover(rsiCTF, ob_level), title = "VARSI enters Overbought zone",
  message = "{{ticker}} — VARSI entered the Overbought zone")
alertcondition(ta.crossunder(rsiCTF, os_level),title = "VARSI enters Oversold zone",
  message = "{{ticker}} — VARSI entered the Oversold zone")


// =====================================================================================================
//  Extra debug: show the resolved Context TF in the Data Window. 
// -----------------------------------------------------------------------------------------------------
dbg = input.bool(false, "Debug: quick method to show selected Context TF in Data Window", group = grpH, active = show_htf,
  tooltip = "Will display as minutes, then hours if > 60, then days if > 1,440.")

htf_mins = htf_secs / 60.0


plot(dbg and htf_mins <= 60                       ? htf_mins        : na, "Context TF (mins)", 
  display = dbg and show_htf ? dw : disnon)
plot(dbg and htf_mins >  60 and htf_mins <= 1440  ? htf_mins / 60.0 : na, "Context TF (hrs)",  
  display = dbg and show_htf ? dw : disnon)
plot(dbg and htf_mins >  1440                     ? htf_mins / 1440.0 : na, "Context TF (days)", 
  display = dbg and show_htf ? dw : disnon)

Overview

RedK DualTF Volume-Accelerated RSI enhances traditional RSI by weighting price changes by trading volume and offering selectable moving average methods (RMA, EMA, SMA, WMA, HMA) for gain and loss smoothing. Users can enable a smoothed main line, a signal line, and a higher-timeframe context RSI with alignment markers to gauge multi-timeframe momentum convergence. Settings allow full customization of lengths, averaging types, volume weighting toggle, and context timeframe multipliers.

Details

Published by

theonetrade on GitHub

Code credit

RedKTrader, as written in the script's header

Draws

Separate pane below the 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

algorithmic-tradingbacktestingbitcoinccxtcrypto-tradingllm-agentoffline-backtestingopen-source-tradingpine-scriptpine-to-pythonpinescriptpynecorepythonquantquantitative-financestrategy-backtestingtechnical-analysistrading-indicatorstrading-strategiestradingview

Settings

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

SettingTypeDefaultVariable
RSI Lengthint14rsiLen
AveragingstringRMAavg_type
Volume WeightedbooltrueVolWeighted
Smoothingint3smooth
AveragingstringWMAsmth_type
Bullishcolorcolor.aquacol_rsi_long
Bearishcolor#f57f17col_rsi_short
Lengthint5signal_len
AveragingstringEMAsig_avg_type
Signal Line Colorcolorcolor.bluecol_signal
Show Context RSIbooltrueshow_htf
Context Multiplier (× chart TF)int5htf_mult
Show all 17 settings
SettingTypeDefaultVariable
Context UpdatestringLive Updatehtf_update
Bullishcolor#33aa00col_rsiH_long
Bearishcolor#ff1111col_rsiH_short
Show Alignment Markersbooltrueshow_align
Debug: quick method to show selected Context TF in Data Windowboolfalsedbg
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

[TVT] OBV with EMA

by namuan
321 stars

Calculates On-Balance Volume (OBV) alongside two Exponential Moving Averages (EMAs) applied directly to the cumulative OBV line. The indicator tracks volume flow relative to price movement and smooths it using short-term and longer-term EMAs to highlight volum

Indicator v6 VolumeOscillators & momentum
Updated 8 days ago · MIT GitHub repository of [TVT] OBV with EMA

Aggregate Signal (v.2)

by capissimo
114 stars

Aggregate Signal (v.2) is an oscillator indicator that combines multiple technical factors into a single composite score. It scales OHLCV data using minimax normalization and evaluates indicators such as MACD, RSI, Stochastic, CCI, Momentum, On-Balance Volume,

Indicator v4 Oscillators & momentumMoving averages Repaints
Updated 2 years ago · None stated GitHub repository of Aggregate Signal (v.2)

Volume-Weighted MACD

by mihakralj
99 stars

This indicator plots a volume-weighted MACD in a separate pane. It subtracts a slow volume-weighted moving average of close from a faster one, then smooths that line with an exponential moving average to form the signal. A column histogram shows the gap betwee

Indicator v5 Oscillators & momentumMoving averages
Updated 8 weeks ago · Apache-2.0 GitHub repository of Volume-Weighted MACD

PPO ATR Bands

by cryptorife
75 stars

PPO ATR Bands plots a percentage price oscillator in a separate pane. It compares a Hull average of typical price with a volume-weighted exponential average of Parabolic SAR, then scales three true-range bands around the slow average into matching oscillator l

Indicator v4 Oscillators & momentumMoving averages
Updated 3 years ago · GPL-3.0 GitHub repository of PPO ATR Bands

RSI-VWMA

by Zettt
43 stars

This indicator calculates the Relative Strength Index using a volume-weighted moving average of the closing price as its source. It plots the resulting oscillator in a separate pane alongside configurable overbought and oversold threshold lines. The plot line

Indicator v4 Oscillators & momentumMoving averages
Updated 1 year ago · None stated GitHub repository of RSI-VWMA

Trap Shorts - Hamza Naveed

by ProfHamzaNaveed
43 stars

This indicator tracks and visualizes cryptocurrency net positioning across multiple derivative exchanges, including Binance, BitMEX, and Kraken. It calculates aggregated net longs, net shorts, net delta, and ratio metrics, or an optional Position RSI, renderin

Indicator v5 VolumeOscillators & momentum
Updated 10 months ago · None stated GitHub repository of Trap Shorts - Hamza Naveed

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