Relative Strength Volatility Variable Bands [DW]
"Relative Strength Volatility Variable Bands [DW]" by DonovanWall, MPL-2.0. Ported to FloScript by FloSignals; modifications under MPL-2.0. Original: Relative Strength Volatility Variable Bands [DW] (v2.0), read 2026-10-12T15:59:18.567Z; source language v4.
Licence: Mozilla Public License 2.0 (MPL-2.0) — full text. The source is published with it, modifications included, under the same licence.
Relative Strength Volatility Variable Bands [DW] by DonovanWall, ported from Pine v4. Overlay indicator with 11 plots, 9 fills, bar/background colouring and 3 inputs.
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © DonovanWall
//██████╗ ██╗ ██╗
//██╔══██╗██║ ██║
//██║ ██║██║ █╗ ██║
//██║ ██║██║███╗██║
//██████╔╝╚███╔███╔╝
//╚═════╝ ╚══╝╚══╝
// ------------------------------------------------------------------------------------------------
// Original author: DonovanWall
// Original title: Relative Strength Volatility Variable Bands [DW]
// Licence: MPL-2.0 (the header above is the original notice, kept verbatim)
// Pine version: 4
// Fetched: 2026-10-12
// Ported to FloScript by FloSignals; modifications under MPL-2.0.
// Converter: @flosignals/floscript 0.1.0, strict mode, score 100/100
// ------------------------------------------------------------------------------------------------
//@floscript=1
//@version=5
// Converted by the FloScript converter from a Pine-compatible v4 source.
indicator("Relative Strength Volatility Variable Bands [DW]", shorttitle="RSVVB [DW]", overlay=true)
//by Donovan Wall
//This is an experimental adaptive trend following study inspired by Giorgos Siligardos's Reverse Engineering RSI and Tushar S. Chande's Variable Moving Average.
//In this study, reverse engineered RSI levels are calculated and used to generate a volatility index for VMA calculation.
//First, price levels are calculated for when RSI will equal 70 and 30. The difference between the levels is taken and normalized to create the volatility index.
//Next, an initial VMA is calculated using the created volatility index. The moving average is an exponential calculation that adjusts the sampling length as volatility changes.
//Then, upper and lower VMAs are calculated by taking a VMA of prices above and below the initial VMA. The midline is produced by taking the median of the upper and lower VMAs.
//Lastly, the band levels are calculated by multiplying the distance from the midline to the upper and lower VMAs by 1, 2, 3, 4, and 5.
//Bar colors are included. They're based on the midline trend and price action relative to the upper and lower VMAs.
//-----------------------------------------------------------------------------------------------------------------------------------------------------------------
//Updates:
// -> Migrated to v4.
// -> Stability Fix: Added correction for NaN values to stabilize initial states.
// -> Reorganized script structure
// -> Updated style theme.
//-----------------------------------------------------------------------------------------------------------------------------------------------------------------
//Functions
//-----------------------------------------------------------------------------------------------------------------------------------------------------------------
//Reverse Engineered RSI function
revrsi(x, t, v) =>
wper = 2 * t - 1
k = 2 / (wper + 1)
uc = 0.0
uc := x > x[1] ? k * (x - x[1]) + (1 - k) * nz(uc[1]) : (1 - k) * nz(uc[1])
dc = 0.0
dc := x > x[1] ? (1 - k) * nz(dc[1]) : k * (x[1] - x) + (1 - k) * nz(dc[1])
val = (t - 1) * (dc * v / (100 - v) - uc)
revrsi = val >= 0 ? x + val : x + val * (100 - v) / v
revrsi
//VMA Function
vma(x, t, o) =>
vma = x
vma := na(vma[1]) ? x : (1 - 1 / t * o) * nz(vma[1]) + 1 / t * o * x
vma
//-----------------------------------------------------------------------------------------------------------------------------------------------------------------
//Inputs
//-----------------------------------------------------------------------------------------------------------------------------------------------------------------
//Source
src = input(defval=close, title="Source")
//Sampling Period
per = input.int(7, minval=1, title="VMA Period")
//Volatility Sampling Period
vper = input.int(defval=7, minval=0, title="Volatility Period")
//-----------------------------------------------------------------------------------------------------------------------------------------------------------------
//Definitions
//-----------------------------------------------------------------------------------------------------------------------------------------------------------------
//Reverse RSI Volatitlity
hiband = revrsi(src, vper, 70)
loband = revrsi(src, vper, 30)
vol = hiband - loband
vi = (vol - ta.lowest(vol, vper)) / (ta.highest(vol, vper) - ta.lowest(vol, vper))
//VMA
ma = vma(src, per, vi)
//Split Means
srch = src > ma ? src : ma
srcl = src < ma ? src : ma
mah = vma(srch, per, vi)
mal = vma(srcl, per, vi)
//Midline
m = (mah + mal) / 2
//Half Mean Range
dist = (mah - mal) / 2
//Levels
h5 = m + dist * 5
h4 = m + dist * 4
h3 = m + dist * 3
h2 = m + dist * 2
h1 = m + dist * 1
l1 = m - dist * 1
l2 = m - dist * 2
l3 = m - dist * 3
l4 = m - dist * 4
l5 = m - dist * 5
//Midline Direction
var mup = 0.0
mup := m > m[1] ? 1 : m < m[1] ? 0 : mup
var mdn = 0.0
mdn := m < m[1] ? 1 : m > m[1] ? 0 : mdn
//Colors
color1 = #0aff68
color2 = #00752d
color3 = #ff0a5a
color4 = #990032
color5 = #ffbf0a
mcolor = mup > 0 ? color1 : mdn > 0 ? color3 : color5
barcolor = mup > 0 and src >= h1 and src > src[1] ? color1 : mup > 0 and src >= h1 and src <= src[1] ? color2 : mdn > 0 and src <= l1 and src < src[1] ? color3 : mdn > 0 and src <= l1 and src >= src[1] ? color4 : color5
//-----------------------------------------------------------------------------------------------------------------------------------------------------------------
//Outputs
//-----------------------------------------------------------------------------------------------------------------------------------------------------------------
//High Levels
h5plot = plot(h5, color=color1, style=plot.style_circles, title="High Level 5")
h4plot = plot(h4, color=color1, style=plot.style_circles, title="High Level 4")
h3plot = plot(h3, color=color1, style=plot.style_circles, title="High Level 3")
h2plot = plot(h2, color=color1, style=plot.style_circles, title="High Level 2")
h1plot = plot(h1, color=color1, style=plot.style_circles, title="High Level 1")
//Midline
mplot = plot(m, color=mcolor, linewidth=3, title="Midline")
//Low Levels
l1plot = plot(l1, color=color3, style=plot.style_circles, title="Low Level 1")
l2plot = plot(l2, color=color3, style=plot.style_circles, title="Low Level 2")
l3plot = plot(l3, color=color3, style=plot.style_circles, title="Low Level 3")
l4plot = plot(l4, color=color3, style=plot.style_circles, title="Low Level 4")
l5plot = plot(l5, color=color3, style=plot.style_circles, title="Low Level 5")
//High Zone Fills
fill(h4plot, h5plot, color=color.new(color1, 75), title="High Zone 4 Fill")
fill(h3plot, h4plot, color=color.new(color1, 80), title="High Zone 3 Fill")
fill(h2plot, h3plot, color=color.new(color1, 85), title="High Zone 2 Fill")
fill(h1plot, h2plot, color=color.new(color1, 90), title="High Zone 1 Fill")
//Middle Zone Fill
fill(h1plot, l1plot, color=color.new(color5, 95), title="Middle Zone Fill")
//Low Zone Fills
fill(l1plot, l2plot, color=color.new(color3, 90), title="Low Zone 1 Fill")
fill(l2plot, l3plot, color=color.new(color3, 85), title="Low Zone 2 Fill")
fill(l3plot, l4plot, color=color.new(color3, 80), title="Low Zone 3 Fill")
fill(l4plot, l5plot, color=color.new(color3, 75), title="Low Zone 4 Fill")
//Bar Color
barcolor(barcolor)
This file is under the Mozilla Public License 2.0; it is a port of the original by DonovanWall, with the original licence header kept and the changes made for FloScript noted in the file.
- v2
Library refresh 2026-10-14
- v1
Library refresh 2026-10-12
Disclaimer. Scripts are written and published by members, or ported by FloSignals from open-source originals, and are their authors' own work and opinion. FloSignals does not review them for correctness and nothing in a script is financial advice or a recommendation to buy or sell anything — read the Risk Disclaimer. Posting here is under the Community Rules; a script that is not the poster's to post can be reported as the Copyright & Takedowns page says.

Comments (0)
No comments yet. Members can leave one.