Strategy · Pine Script v6 · Own pane

RSI with Bollinger Bands

by pineforge-4pass· code credited to PineForge contributors 2026

Calculates the Relative Strength Index (RSI) and wraps Bollinger Bands directly around the RSI series rather than price.

View on GitHub

GitHub stars1on the repository
Pine versionv6current
Lines of code44
Settings3inputs
LicenceApache-2.0
Last update5 days ago23 Oct 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 strategy, select all of the template text and paste. Press Save and give it a name.
  4. 4Add it to the chartPress Add to chart. The trades and results appear in the Strategy Tester tab; adjust the settings with the gear icon.

Source Code

44 lines of Pine Script v6 from validation/ta-rsi-bb-self-bands-01/strategy.pine, published under Apache-2.0. Keep the author's credit and licence lines when you reuse it.

strategy.pine
// This Pine Script® code is licensed under Apache-2.0
// SPDX-License-Identifier: Apache-2.0
// © PineForge contributors 2026
//
// PF probe 31 — Bollinger bands wrapped around RSI itself
// Purpose: parity test for ta.sma + ta.stdev applied directly to ta.rsi
// (TA-on-TA chain) with band-cross + bar-direction confirm entries.
//
//@version=6
strategy("RSI with Bollinger Bands", overlay=false, initial_capital=1000000, process_orders_on_close=false, pyramiding=1, commission_type=strategy.commission.percent, commission_value=0, slippage=0, default_qty_type=strategy.fixed, default_qty_value=1)

// === Inputs ===
rsiLen  = input.int(14, "RSI Length", minval=1)
bbLen   = input.int(50, "BB Length on RSI", minval=5)
bbMult  = input.float(2.0, "BB Mult", step=0.1)

// === RSI ===
rsiVal = ta.rsi(close, rsiLen)

// === Bollinger Bands on RSI itself ===
rsiBBMid = ta.sma(rsiVal, bbLen)
rsiDev   = ta.stdev(rsiVal, bbLen) * bbMult
rsiBBUp  = rsiBBMid + rsiDev
rsiBBDn  = rsiBBMid - rsiDev

// === Signals: RSI crosses its own BB ===
longCond  = rsiVal < rsiBBDn and rsiVal > rsiVal[1]
shortCond = rsiVal > rsiBBUp and rsiVal < rsiVal[1]

if longCond
    strategy.entry("Long", strategy.long)
if shortCond
    strategy.entry("Short", strategy.short)

// === Exit at RSI midline ===
if strategy.position_size > 0 and rsiVal > rsiBBMid
    strategy.close("Long")
if strategy.position_size < 0 and rsiVal < rsiBBMid
    strategy.close("Short")

plot(rsiVal, "RSI", color=color.blue, linewidth=2)
plot(rsiBBUp, "RSI BB Upper", color=color.red)
plot(rsiBBMid, "RSI BB Mid", color=color.gray)
plot(rsiBBDn, "RSI BB Lower", color=color.green)

Overview

RSI with Bollinger Bands enters long positions when the RSI drops below its lower band and hooks back upward, and enters short positions when the RSI exceeds the upper band and turns downward. Positions exit when the RSI crosses back over its moving average midline. Key settings adjust RSI length, Bollinger Band period, and standard deviation multiplier. All plots display in a separate pane with no stop loss defined.

Details

Published by

pineforge-4pass on GitHub

Code credit

PineForge contributors 2026, as written in the script's header

Type

Strategy, Pine Script v6

Draws

Separate pane below the chart

Category

Oscillators & momentum, Volatility & bands, Mean reversion

Markets

Any symbol

Timeframes

Any timeframe

Risk Notes

  • The strategy enters trades without a stop loss

Topics

algorithmic-tradingbacktestingparitypine-scriptpinescriptquantitative-financetest-corpustradingview

Settings

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

SettingTypeDefaultVariable
RSI Lengthint14rsiLen
BB Length on RSIint50bbLen
BB Multfloat2.0bbMult
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 strategy combines Larry Williams' Vix Fix synthetic volatility indicator with Bollinger Bands. It calculates standard and inverted Williams Vix Fix metrics, displaying them as histogram columns with standard deviation bands in a separate pane. Long entrie

Strategy v4 Volatility & bandsOscillators & momentum
Updated 2 months ago · None stated GitHub repository of Williams Vix Fix Strategy [Alorse]

2xTP, SL to Entry

by hasnocool
106 stars

This strategy executes mean-reversion trades based on Bollinger Bands and the Stochastic Oscillator. Long orders trigger when price dips below the lower band alongside a bullish Stochastic crossover, with an optional oversold threshold. Short orders execute on

Strategy v5 Mean reversionOscillators & momentum
Updated 2 years ago · GPL-3.0 GitHub repository of 2xTP, SL to Entry

Greeffer BB Strategy

by SammyEnigma
18 stars

This strategy fades Bollinger Band extremes using the close. It enters short when price crosses above the upper band and the 14-period RSI is above 70, and enters long when price crosses below the lower band and RSI is below 30. It closes half of an open short

Strategy v4 Volatility & bandsOscillators & momentum
Updated 6 years ago · None stated GitHub repository of Greeffer BB Strategy

Alpy Vix

by avatar-lavventura
2 stars

This strategy plots the Williams Vix Fix indicator as a histogram in a separate pane to detect potential trend reversals. It calculates the Vix Fix value using a lookback period and standard deviation bands derived from Bollinger Bands on the Vix Fix. Multiple

Strategy v4 Oscillators & momentumVolatility & bands Repaints
Updated 7 months ago · None stated GitHub repository of Alpy Vix

This strategy calculates intraday volatility mean reversion using session VWAP standard deviation bands, RSI overbought and oversold levels, and candle wick exhaustion ratios. It enters trades when price reaches statistical extremes filtered by RSI and wick co

Strategy v6 Mean reversionVolatility & bands
Updated 7 months ago · MIT GitHub repository of Intraday Volatility Reversion Z-Score

More strategys

Trade Your Charts With a Regulated Broker

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

Compare brokers