Indicator · Pine Script v4 · On the chart

RSI Bounce

by blackcat1402

RSI Bounce calculates custom Relative Strength Index levels scaled back onto price, creating nine price-equivalent RSI band series centered around a median RSI baseline.

View on GitHub

GitHub stars3on the repository
Pine versionv4older, still runs
Lines of code157
Settings7inputs
LicenceMIT
Last update5 years ago19 Dec 2020

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

157 lines of Pine Script v4 from indicator/multi/rsi_bounce.pine, published under MIT. Keep the author's credit and licence lines when you reuse it.

rsi_bounce.pine
//@version=4



study("RSI Bounce", shorttitle="RSI Bounce", overlay=true)



mcf = input(title="MACD Fast",   type=input.integer, defval = 4,  minval = 1)
mcs = input(title="MACD Slow",   type=input.integer, defval = 21, minval = 1)
mcl = input(title="MACD Length", type=input.integer, defval = 4,  minval = 1)

rco = input(title="RSI Confirmation", type=input.integer, defval=75,   minval=1,     maxval=100, step=1   ) // Percentage requirement of RSI crossing against close price.
rmu = input(title="RSI Multiplier",   type=input.float,   defval=2.6,  minval=0.1,               step=0.2 )
rsl = input(title="RSI Length",       type=input.integer, defval=80,   minval=1,                 step=1   )
rlm = input(title="RSI Lift",         type=input.float,   defval=0.05, minval=0.001,             step=0.01)



new_bet(num, thr, dev) =>
  thr - dev < num and num < dev + thr

new_ema(s, p) =>
    ema = 0.
    sf = 2 / (p + 1)
    ema := nz(ema[1] + sf * (s - ema[1]), s)

// new_mds returns the MACD indicator for short signals.
new_mds() =>
    // RSI overbought threshold.
    rob = 80

    mup = rma( max(change(close), 0), 3)
    mdo = rma(-min(change(close), 0), 3)

    rsi = mdo == 0 ? 100 : mup == 0 ? 0 : 100 - (100 / (1 + mup / mdo))
    wob = rsi[0] >= rob or rsi[1] >= rob or rsi[2] >= rob or rsi[3] >= rob or rsi[4] >= rob or rsi[5] >= rob

    [mcd,_,_] = macd(close[0], mcf, mcs, mcl)
    sig = ema(mcd, mcl)

    cross(mcd, sig) and mcd < sig and wob ? true : false

// new_mdl returns the MACD indicator for long signals.
new_mdl() =>
    // RSI oversold threshold.
    ros = 20

    mup = rma( max(change(close), 0), 3)
    mdo = rma(-min(change(close), 0), 3)

    rsi = mdo == 0 ? 100 : mup == 0 ? 0 : 100 - (100 / (1 + mup / mdo))
    wos = rsi[0] <= ros or rsi[1] <= ros or rsi[2] <= ros or rsi[3] <= ros or rsi[4] <= ros or rsi[5] <= ros

    [mcd,_,_] = macd(close[0], mcf, mcs, mcl)
    sig = ema(mcd, mcl)

    cross(mcd, sig) and mcd > sig and wos ? true : false

// new_per calculates the percentage of a fraction based on the given absolute
// value.
//
//     new_per(100, 5) => 5
//
new_per(abs, fra) =>
    fra * 100 / abs

// new_rsi returns a new RSI series based on the given value and length. Here v
// means value and l means length.
new_rsi(v, l) =>
    src = close
    auc = new_ema(max(src - src[1], 0), 2 * l - 1)
    adc = new_ema(max(src[1] - src, 0), 2 * l - 1)

    quo = (l - 1) * (adc * v / (100 - v) - auc)
    iff(quo >= 0, src + quo, src + quo * (100 - v) / v)



// We track the total of RSI series we work with. This is used for dynamic
// signal confirmation. We want to get a certain percentage of confirmations in
// order to trigger long or short. Note this must align with the number of RSI
// bands configured below. Var trs means total RSI series.
trs = 9

// We hard code the RSI median since the RSI indicators evolve around the idea
// of reversion to the mean. Manipulating the median should not perform better
// over time.
rsv = 50

rb1 = new_rsi(rsv+4*rmu, rsl) // RSI band series one. This is the highest.
rb2 = new_rsi(rsv+3*rmu, rsl) // RSI band series two.
rb3 = new_rsi(rsv+2*rmu, rsl) // RSI band series three.
rb4 = new_rsi(rsv+1*rmu, rsl) // RSI band series four.
rb5 = new_rsi(rsv+0*rmu, rsl) // RSI band series five. This is the median.
rb6 = new_rsi(rsv-1*rmu, rsl) // RSI band series six.
rb7 = new_rsi(rsv-2*rmu, rsl) // RSI band series seven.
rb8 = new_rsi(rsv-3*rmu, rsl) // RSI band series eight.
rb9 = new_rsi(rsv-4*rmu, rsl) // RSI band series nine. This is the lowest.



// new_acs verifies a series crossover. Here sco means series crossover.
new_acs() =>
    // We track the count of activated crossover signals in order to calculate a
    // percentage of active crossover signals based on the total RSI series. Var
    // acs means active crossover signals.
    acs = 0

    src = low

    // Collect all short signals based on the RSI series crossing. We verify how
    // many confirmations we get in order to derive the probability of a
    // successful trade.
    acs := rb1 < src ? acs + 1 : acs
    acs := rb2 < src ? acs + 1 : acs
    acs := rb3 < src ? acs + 1 : acs
    acs := rb4 < src ? acs + 1 : acs
    acs := rb5 < src ? acs + 1 : acs
    acs := rb6 < src ? acs + 1 : acs
    acs := rb7 < src ? acs + 1 : acs
    acs := rb8 < src ? acs + 1 : acs
    acs := rb9 < src ? acs + 1 : acs

    new_per(trs, acs) >= rco

new_rss() =>
    // One activation decision is made based on the amount of RSI series
    // crossings against the close price. Var rcc means RSI crossing
    // confirmation.
    rcc = new_acs()

    // We retrun 1 if we get sufficient short signals. We return na if we did
    // not detect sufficient short signals.
    rcc ? 1 : na



// plot(rb1, title="Resistance", color=color.gray, linewidth=0, transp=50)
// plot(rb2, title="Resistance", color=color.gray, linewidth=0, transp=50)
// plot(rb3, title="Resistance", color=color.gray, linewidth=0, transp=50)
// plot(rb4, title="Resistance", color=color.gray, linewidth=0, transp=50)
plot(rb5, title="Resistance", color=color.gray, linewidth=0, transp=50)
// plot(rb6, title="Resistance", color=color.gray, linewidth=0, transp=50)
// plot(rb7, title="Resistance", color=color.gray, linewidth=0, transp=50)
// plot(rb8, title="Resistance", color=color.gray, linewidth=0, transp=50)
// plot(rb9, title="Resistance", color=color.gray, linewidth=0, transp=50)



// plotshape(new_mds(), text="MACD", title="Indicator", location=location.abovebar, style=shape.labeldown, size=size.tiny, color=color.red,   textcolor=color.white, transp=0)
// plotshape(new_mdl(), text="MACD", title="Indicator", location=location.belowbar, style=shape.labelup,   size=size.tiny, color=color.green, textcolor=color.white, transp=0)
// plotshape(new_rss(), text="RSI",  title="Indicator", location=location.abovebar, style=shape.labeldown, size=size.tiny, color=color.red,   textcolor=color.white, transp=0)

act = new_mds() and new_rss()

plotshape(act, text="SHORT", title="Indicator", location=location.abovebar, style=shape.labeldown, size=size.tiny, color=color.red,   textcolor=color.white, transp=0)

Overview

RSI Bounce combines short-term RSI extreme checks with customized MACD signal line crossovers to identify potential bounce conditions directly on the main chart. Users can adjust MACD fast, slow, and signal lengths alongside RSI confirmation thresholds, multipliers, and smoothing periods. The indicator overlays its calculated band structures directly on the price chart.

Details

Published by

blackcat1402 on GitHub

Type

Indicator, Pine Script v4

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.

Settings

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

SettingTypeDefaultVariable
MACD Fastint4mcf
MACD Slowint21mcs
MACD Lengthint4mcl
RSI Confirmationint75rco
RSI Multiplierfloat2.6rmu
RSI Lengthint80rsl
RSI Liftfloat0.05rlm
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

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]
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

Antigravity Elite

by eltonaguiar
4 stars

Antigravity Elite is an overlay indicator that screens price with seven selectable components: Mercury Fear, Connors RSI-2, volatility-spike reversal, EMA stack, Supertrend, multi-sigma bands, and an optional funding proxy. Auto-Detect chooses one method, whil

Indicator v6 Oscillators & momentumMoving averages
Updated 2 days ago · None stated GitHub repository of Antigravity Elite

Ari zScore

by alessioricco
1 stars

Ari zScore calculates a z-score as the difference between a fast and a slow simple moving average of close, divided by the standard deviation of close. It plots numbered triangles above and below price bars when that value enters fixed magnitude bands, optiona

Indicator v4 Oscillators & momentumMoving averages
Updated 2 years ago · Apache-2.0 GitHub repository of Ari zScore

BB_signal1

by subhrapratim07
1 stars

This indicator plots standard Bollinger Bands consisting of an upper band, lower band, and a simple moving average directly on the price chart. It calculates the Relative Strength Index to identify overbought conditions. A bearish signal displays as a red down

Indicator v5 Volatility & bandsOscillators & momentum
Updated 2 years ago · None stated GitHub repository of BB_signal1

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