Indicator · Pine Script v6 · On the chart

Reversal Master [SimpleAlgo]

by theonetrade

This indicator tracks market momentum using a smoothed Relative Volatility Index to identify overbought and oversold extremes.

View on GitHub

GitHub stars34on the repository
Pine versionv6current
Lines of code124
Settings16inputs
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

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

reversal_master_simplealgo_Oa4tmc4E.pine
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
//@version=6
indicator("Reversal Master [SimpleAlgo]", "Reversal Master", overlay = true, max_labels_count = 500)

// ═══════════════════════════════ Inputs ═══════════════════════════════
grpS = "Signals"
showSig   = input.bool(true, "Reversal signals", group = grpS, tooltip = "Momentum leaves an extreme after a stretch. Marked Strong when price reached the outer bands during that stretch.")
showReady = input.bool(true, "Ready alerts", group = grpS, tooltip = "Momentum has entered an extreme. A reversal signal may follow when it leaves.")
volLen    = input.int(10, "Momentum length", minval = 2, maxval = 100, group = grpS)
volSmooth = input.int(14, "Momentum smoothing", minval = 1, maxval = 100, group = grpS)
hiLvl     = input.int(80, "Extreme high", minval = 51, maxval = 99, group = grpS)
loLvl     = input.int(20, "Extreme low", minval = 1, maxval = 49, group = grpS)
minGap    = input.int(5, "Min bars between same-direction signals", minval = 0, maxval = 200, group = grpS)
readyGap  = input.int(8, "Min bars between Ready tags", minval = 0, maxval = 200, group = grpS)

grpB = "Reversal bands"
showBands = input.bool(true, "Show bands", group = grpB)
bandLen   = input.int(34, "Band length", minval = 5, maxval = 300, group = grpB)
bandMult  = input.float(2.0, "Band distance", minval = 0.5, maxval = 10.0, step = 0.1, group = grpB, tooltip = "Distance of the first band from the center, in volatility units. The second and third bands sit further out.")

grpC = "Trend candles"
showCandles = input.bool(true, "Color candles by trend angle", group = grpC)
angLen      = input.int(34, "Trend angle length", minval = 5, maxval = 300, group = grpC)

grpD = "Look"
colUp  = input.color(#3DDC97, "Up",   inline = "c", group = grpD)
colDn  = input.color(#F2607A, "Down", inline = "c", group = grpD)
colMid = input.color(#6B7280, "Flat", inline = "c", group = grpD)

// ═══════════════════════════════ Momentum: Relative Volatility Index ═══════════════════════════════
// Standard RVI: volatility (standard deviation) split into up-close and down-close days, then smoothed.
// Above the high level = upside pressure stretched. Below the low level = downside pressure stretched.
float sd  = ta.stdev(close, volLen)
float chg = ta.change(close)
float upV = ta.ema(chg > 0 ? sd : 0.0, volSmooth)
float dnV = ta.ema(chg <= 0 ? sd : 0.0, volSmooth)
float rvi = upV + dnV > 0 ? 100 * upV / (upV + dnV) : 50.0

// ═══════════════════════════════ Reversal bands ═══════════════════════════════
// Center: EMA of typical price. Volatility unit: blend of standard deviation and ATR, lightly smoothed.
// Three tiers on each side mark how far price has stretched from normal.
float basis = ta.ema(hlc3, bandLen)
float unit  = ta.ema(math.avg(ta.stdev(close, bandLen), ta.atr(bandLen)), 5)
float u1 = basis + unit * bandMult
float u2 = basis + unit * (bandMult + 0.75)
float u3 = basis + unit * (bandMult + 1.5)
float l1 = basis - unit * bandMult
float l2 = basis - unit * (bandMult + 0.75)
float l3 = basis - unit * (bandMult + 1.5)

pU1 = plot(showBands ? u1 : na, "Upper 1", color = color.new(colDn, 80))
pU2 = plot(showBands ? u2 : na, "Upper 2", color = color.new(colDn, 65))
pU3 = plot(showBands ? u3 : na, "Upper 3", color = color.new(colDn, 40))
pL1 = plot(showBands ? l1 : na, "Lower 1", color = color.new(colUp, 80))
pL2 = plot(showBands ? l2 : na, "Lower 2", color = color.new(colUp, 65))
pL3 = plot(showBands ? l3 : na, "Lower 3", color = color.new(colUp, 40))
fill(pU1, pU2, color = color.new(colDn, 93), title = "Upper zone 1")
fill(pU2, pU3, color = color.new(colDn, 86), title = "Upper zone 2")
fill(pL1, pL2, color = color.new(colUp, 93), title = "Lower zone 1")
fill(pL2, pL3, color = color.new(colUp, 86), title = "Lower zone 2")

// ═══════════════════════════════ Trend candles ═══════════════════════════════
// Trend angle: slope of a linear regression line, measured in ATR units across the window,
// converted to an angle in degrees. Steeper up = stronger mint, steeper down = stronger coral, flat = grey.
float slope = ta.linreg(close, angLen, 0) - ta.linreg(close, angLen, 1)
float atrA  = ta.atr(angLen)
float steep = ta.ema(atrA > 0 ? slope / atrA * angLen : 0.0, 5)
float deg   = math.atan(steep) * 180 / math.pi
color angCol = deg >= 0 ? color.from_gradient(deg, 0, 60, colMid, colUp) : color.from_gradient(deg, -60, 0, colDn, colMid)
color candleC = close >= open ? angCol : color.from_gradient(0.45, 0.0, 1.0, angCol, #0F1117)
barcolor(showCandles ? candleC : na, title = "Trend candles")

// ═══════════════════════════════ Setups and signals (confirmed bars only) ═══════════════════════════════
bool enterHi = ta.crossover(rvi, hiLvl)
bool leaveHi = ta.crossunder(rvi, hiLvl)
bool enterLo = ta.crossunder(rvi, loLvl)
bool leaveLo = ta.crossover(rvi, loLvl)
float atr30  = ta.atr(30)

var bool readyDn = false, var int tierDn = 0, var int lastDnBar = -100000
var bool readyUp = false, var int tierUp = 0, var int lastUpBar = -100000
var int lastReadyBar = -100000, var int lastSigBar = -100000
bool sigUpNow = false, bool sigDnNow = false, bool readyUpNow = false, bool readyDnNow = false

if barstate.isconfirmed and not na(atr30)
    // Track how far price stretched while momentum is extreme
    if readyDn
        tierDn := math.max(tierDn, high > u3 ? 3 : high > u2 ? 2 : high > u1 ? 1 : 0)
    if readyUp
        tierUp := math.max(tierUp, low < l3 ? 3 : low < l2 ? 2 : low < l1 ? 1 : 0)

    // Momentum enters an extreme: setup starts
    if enterHi
        readyDn := true, tierDn := high > u3 ? 3 : high > u2 ? 2 : high > u1 ? 1 : 0, readyDnNow := true
        if showReady and bar_index - lastReadyBar >= readyGap
            lastReadyBar := bar_index
            label.new(bar_index, high + atr30 * (bar_index - lastSigBar <= 3 ? 1.3 : 0.15), "Ready ▼", style = label.style_label_down, color = color.new(colDn, 100), textcolor = color.new(colDn, 20), size = size.small, tooltip = "Upside momentum is stretched. A sell-side reversal signal may follow.")
    if enterLo
        readyUp := true, tierUp := low < l3 ? 3 : low < l2 ? 2 : low < l1 ? 1 : 0, readyUpNow := true
        if showReady and bar_index - lastReadyBar >= readyGap
            lastReadyBar := bar_index
            label.new(bar_index, low - atr30 * (bar_index - lastSigBar <= 3 ? 1.3 : 0.15), "Ready ▲", style = label.style_label_up, color = color.new(colUp, 100), textcolor = color.new(colUp, 20), size = size.small, tooltip = "Downside momentum is stretched. A buy-side reversal signal may follow.")

    // Momentum leaves the extreme: reversal signal
    if leaveHi and readyDn
        if showSig and bar_index - lastDnBar >= minGap
            bool strong = tierDn >= 2
            label.new(bar_index, high + atr30 * 0.8, strong ? "▼ Strong" : "▼", style = label.style_label_down, color = colDn, textcolor = #0F1117, size = size.normal, tooltip = "Upside momentum has left its extreme." + (strong ? "\nPrice stretched into the outer bands during the move." : "\nPrice did not reach the outer bands."))
            lastDnBar := bar_index, lastSigBar := bar_index, sigDnNow := true
            alert("Reversal Master: sell-side reversal" + (strong ? " (strong)" : ""), alert.freq_once_per_bar_close)
        readyDn := false
    if leaveLo and readyUp
        if showSig and bar_index - lastUpBar >= minGap
            bool strong = tierUp >= 2
            label.new(bar_index, low - atr30 * 0.8, strong ? "▲ Strong" : "▲", style = label.style_label_up, color = colUp, textcolor = #0F1117, size = size.normal, tooltip = "Downside momentum has left its extreme." + (strong ? "\nPrice stretched into the outer bands during the move." : "\nPrice did not reach the outer bands."))
            lastUpBar := bar_index, lastSigBar := bar_index, sigUpNow := true
            alert("Reversal Master: buy-side reversal" + (strong ? " (strong)" : ""), alert.freq_once_per_bar_close)
        readyUp := false

// ═══════════════════════════════ Alerts ═══════════════════════════════
alertcondition(sigUpNow,   "Buy-side reversal",  "Reversal Master: buy-side reversal")
alertcondition(sigDnNow,   "Sell-side reversal", "Reversal Master: sell-side reversal")
alertcondition(readyUpNow, "Ready: buy side",    "Reversal Master: downside momentum stretched")
alertcondition(readyDnNow, "Ready: sell side",   "Reversal Master: upside momentum stretched")

Overview

Reversal Master [SimpleAlgo] plots multi-tiered volatility bands around an EMA basis, calculated from standard deviation and ATR, to measure price extension. The script generates visual reversal signals and ready alerts when momentum exits extreme zones, marking stronger signals if price touches the outer bands. It also offers optional candle coloring based on trend angle. All drawings display directly on the main price chart.

Details

Published by

theonetrade on GitHub

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

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
Reversal signalsbooltrueshowSig
Ready alertsbooltrueshowReady
Momentum lengthint10volLen
Momentum smoothingint14volSmooth
Extreme highint80hiLvl
Extreme lowint20loLvl
Min bars between same-direction signalsint5minGap
Min bars between Ready tagsint8readyGap
Show bandsbooltrueshowBands
Band lengthint34bandLen
Band distancefloat2.0bandMult
Color candles by trend anglebooltrueshowCandles
Show all 16 settings
SettingTypeDefaultVariable
Trend angle lengthint34angLen
Upcolor#3DDC97colUp
Downcolor#F2607AcolDn
Flatcolor#6B7280colMid
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

Moon Dev Lunar Sniper

by moondevonyt
98 stars

Moon Dev Lunar Sniper is a multi-indicator overlay that scores confluence across fast and slow EMAs, RSI, MACD, DMI, and BB width to fire signals only when score meets the minimum threshold. It plots buy and sell signals on the price chart, highlights cosmic b

Indicator v6 TrendOscillators & momentum Repaints
Updated 2 months ago · Custom licence GitHub repository of Moon Dev Lunar Sniper
14 stars

Self-Aware Trend System calculates volatility-adaptive ATR trailing bands using a Trend Quality Index engine that evaluates market efficiency, momentum persistence, and structural pivots. It plots adaptive trend bands and character-flip trend signals directly

Indicator v6 TrendVolatility & bands
Updated 6 weeks ago · MIT GitHub repository of Self-Aware Trend System [WillyAlgoTrader]

Cerebr Wave

by jerryinyang
5 stars

Cerebr Wave is an overlay indicator that combines multi-timeframe Keltner Channels with a Wave Trend oscillator to analyze market structure and momentum. It calculates higher-timeframe and lower-timeframe Keltner Channels alongside Wave Trend crossover signals

Indicator v4 TrendOscillators & momentum
Updated 2 years ago · None stated GitHub repository of Cerebr Wave

Cyber HUD XAU

by panzmoravylab
3 stars

Cyber HUD XAU is an overlay indicator designed for XAUUSD that combines trend, momentum, and volatility filters. It calculates fast and slow ATR ratios alongside local price ranges to detect consolidation and chop filter states. The script evaluates candle bod

Indicator v6 Volatility & bandsOscillators & momentum
Updated 4 months ago · None stated GitHub repository of Cyber HUD XAU

Setup-1

by IAMATOMIC001
3 stars

This indicator plots multiple technical analysis components directly on the price chart, including a Nadaraya-Watson envelope, pivot-based trendlines, and a kernel regression oscillator. It also renders visual overlay panels for the Relative Strength Index and

Indicator v5 TrendOscillators & momentum Repaints
Updated 1 year ago · None stated GitHub repository of Setup-1

Skew Weighted Average Price (SWAP) calculates a skew-weighted average price for nuanced analysis of price dynamics and potential trading opportunities. The script determines skew by comparing smoothed positive and negative true ranges derived from price direct

Indicator v5 Volatility & bandsSupport & resistance
Updated 2 years ago · GPL-3.0 GitHub repository of Skew Weighted Average Price (SWAP)

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