Strategy · Pine Script v4 · On the chart

BB+RSI+OBV

by hasnocool· code credited to atakhadivi

This strategy combines Bollinger Bands, the Relative Strength Index (RSI), and On-Balance Volume (OBV) to generate trade signals directly on the price chart.

View on GitHub

GitHub stars106on the repository
Pine versionv4older, still runs
Lines of code23
Settings2inputs
LicenceGPL-3.0
Last update2 years ago18 Sep 2024

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

23 lines of Pine Script v4 from BB+RSI+OBV.pine, published under GPL-3.0. Keep the author's credit and licence lines when you reuse it.

BB+RSI+OBV.pine
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © atakhadivi
//@version=4
strategy("BB+RSI+OBV", overlay=true)
src = close
obv = cum(sign(change(src)) * volume)
// plot(obv, color=#3A6CA8, title="OnBalanceVolume")
source = close
length = input(20, minval=1)
mult = input(2.0, minval=0.001, maxval=50)
basis = sma(source, length)
dev = mult * stdev(source, length)
upper = basis + dev
lower = basis - dev
buyEntry = source > basis and rsi(close, 14) > 50 and obv[1] < obv 
buyExit = source < lower
sellEntry = source < basis and rsi(close, 14) < 50 and obv[1] > obv
sellExit = source > upper
strategy.entry("BBandLE", strategy.long, stop=lower, oca_name="BollingerBands", oca_type=strategy.oca.cancel, comment="BBandLE", when=buyEntry)
strategy.exit(id='BBandLE', when=buyExit)
strategy.entry("BBandSE", strategy.short, stop=upper, oca_name="BollingerBands", oca_type=strategy.oca.cancel, comment="BBandSE", when=sellEntry)
strategy.exit(id='BBandSE', when=sellExit)
Expand (25 lines)

Overview

Long entries trigger when price is above the middle SMA band, RSI is over 50, and OBV is rising. Short entries trigger when price is below the middle band, RSI is under 50, and OBV is falling. Exits occur when price crosses outer band thresholds. Settings allow adjusting the Bollinger Bands length and standard deviation multiplier.

Details

Published by

hasnocool on GitHub

Code credit

atakhadivi, as written in the script's header

Type

Strategy, Pine Script v4

Draws

On the price chart

Category

Volatility & bands, Oscillators & momentum, Volume, Moving averages

Markets

Crypto

Timeframes

M15-H1

Risk Notes

  • The strategy enters trades without a stop loss

Topics

analysisbtcusdtcryptocurrencydatapandaspythonsimulationtradingtradingview

Settings

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

SettingTypeDefaultVariable
lengthint20length
multfloat2.0mult
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

CombinedBinHAndClucV8

by viktors1982
36 stars

This strategy trades on the price chart using multiple indicators. It enters long positions when price dips meet conditions on Bollinger Bands 40 and 20, RSI, MFI, volume and other thresholds. It exits at custom ROI profit levels based on RSI or after timeout

Strategy v4 Oscillators & momentumMoving averages Repaints
Updated 2 years ago · None stated GitHub repository of CombinedBinHAndClucV8
330 stars

This strategy plots MACD line, signal line, Bollinger Bands, and RSI on the price chart. It signals long entries on MACD crossover above signal with RSI below 50 and price below BB basis, plus optional DMI filter. Short entries are available but disabled by de

Strategy v5 Oscillators & momentumVolatility & bands
Updated 2 months ago · None stated GitHub repository of MACD + BB + RSI [Alorse]
257 stars

This overlay strategy is built for ES futures on the one-minute chart. It plots a volume-weighted moving average of price opens and standard-deviation bands at Fibonacci ratios, plus a second longer volume-weighted average from a higher-timeframe open. Call an

Strategy v5 Volatility & bandsMoving averages
Updated 6 weeks ago · None stated GitHub repository of ES Futures 1M No Repaint
105 stars

This overlay strategy looks for gold scalps from break of structure and change of character. It enters long when a bullish break, a bullish character change, and an optional volume filter align, and short on the opposite set. Optional RSI levels can block trad

Strategy v6 SMC / ICT / price actionOscillators & momentum Repaints

Take Profits & Stop Losses

by PythonForForex
64 stars

This educational strategy demonstrates moving average crossovers filtered by RSI momentum, incorporating ATR-based risk management. It calculates a 10-period SMA, a 30-period SMA, a 14-period RSI, and a 14-period ATR. Long entries trigger when the fast SMA cro

Strategy v5 Moving averagesOscillators & momentum
Updated 4 years ago · None stated GitHub repository of Take Profits & Stop Losses

Momentum Rider DAILY FINAL

by greenpeas007
58 stars

This strategy combines exponential moving averages (EMA 9, 21, 50), RSI, MACD, and Supertrend indicators to enter long positions. It triggers trades using six dynamic setups based on momentum breakouts, EMA crossovers, and pullbacks. Position sizing is compute

Strategy v6 TrendOscillators & momentum Repaints
Updated 4 months ago · Custom licence GitHub repository of Momentum Rider DAILY FINAL

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