Strategy · Pine Script v4 · On the chart

RSI/BB/60 Strategy

by SammyEnigma· code credited to Greeffer

This strategy plots Bollinger Bands on the price chart and calculates RSI plus Bollinger Band width from one shared length.

View on GitHub

GitHub stars18on the repository
Pine versionv4older, still runs
Lines of code63
Settings3inputs
LicenceNone statedfile: MPL-2.0
Last update6 years ago15 Oct 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 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

63 lines of Pine Script v4 from BBW-RSI-60-Strategy.pine, published under MPL-2.0 (file header). Keep the author's credit and licence lines when you reuse it.

BBW-RSI-60-Strategy.pine
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © Greeffer
// github.com/modster or modster.github.io
// 210.14% profit in backtesting. Trading BTCUSDT 60 minute time frame on Binance Spot Exchange

//@version=4

// S t u d y
// study('BBW/RSI/60 Study', 'BBW/RSI/60 Study', overlay=true, precision=4)

// S t r a t e g y
strategy("RSI/BB/60 Strategy", "BBW/RSI/60 Strategy", true, format=format.inherit, 
     scale=scale.right, precision=5, pyramiding=10, default_qty_type=strategy.percent_of_equity,
     default_qty_value=10, initial_capital=100000, currency=currency.USD,
     commission_type=strategy.commission.percent, commission_value=0.075,
     process_orders_on_close=true, calc_on_every_tick=false)

// I N P U T
source = close
sell = input(title="Sell", defval=80, minval=0, maxval=100)
buy = input(title="Buy", defval=20, minval=0, maxval=100)
length = input(title="Length", defval=14, minval=1, maxval=500)

// R S I
myRsi = rsi(source, length)
plot(myRsi, title="myRsi", color=color.blue, display=display.none)
//hline(buy, title='buy', color=color.red, display=display.none) //linestyle=hline.style_dotted, linewidth=1)
//hline(sell, title='sell', color=color.red, display=display.none) //linestyle=hline.style_dotted, linewidth=1)

// B o l l i n g e r   B a n d s 
[middle, upper, lower] = bb(source, length, 2)
plot(middle, title="middle", color=color.red, linewidth=2, style=plot.style_line, transp=70)
plot(upper, title="upper", color=color.green, linewidth=2, style=plot.style_line, transp=70)
plot(lower, title="lower", color=color.green,  linewidth=2, style=plot.style_line, transp=70)

// B o l l i n g e r  B a n d  W i d t h 
bbW = bbw(source, length, 2)
plot(bbW, title="bbWidth", color=color.orange, display=display.none)

//  C o n d i t i o n s 
buyCondition = crossunder(bbW, 0.01)
sellCondition = cross(source, upper) and myRsi >= sell
stopCondition = crossunder(source, middle) and bbW>0.05

if(stopCondition)
    strategy.close("long", when=strategy.position_size > 0, comment="stop", qty_percent=100)

if(buyCondition)
    strategy.entry("long", strategy.long, qty=100, stop=lower, oca_name="long0", oca_type=strategy.oca.reduce, when=strategy.position_size <= 0)

if(sellCondition)
    strategy.order("short", strategy.short, qty=10, stop=upper, oca_name="long0", oca_type=strategy.oca.reduce, when=myRsi>=95)
    strategy.order("short", strategy.short, qty=20, stop=upper, oca_name="long0", oca_type=strategy.oca.reduce, when=myRsi>=80)
    strategy.order("short", strategy.short, qty=10, stop=upper, oca_name="long0", oca_type=strategy.oca.reduce, when=strategy.position_size>40)

// B U Y
//alertcondition(buyCondition, title='Buy', message='{"direction":"buy","close":"{{close}}","time":"{{time}}"}')

// S E L L
//alertcondition(sellCondition, title='Sell', message='{"direction":"sell","close":"{{close}}","time":"{{time}}"}')

// S T O P
//alertcondition(stopCondition, title='Stop', message='{"direction":"stop","close":"{{close}}","time":"{{time}}"}')

Overview

RSI/BB/60 Strategy enters long when band width crosses under 0.01, with a stop order at the lower band. It adds short orders when price crosses the upper band and RSI meets the sell threshold, subject to extra RSI and size checks. It closes the long when price crosses under the middle band and band width exceeds 0.05. The buy, sell, and length inputs set RSI levels and the calculation period. Pyramiding is on and no stop loss is set by default.

Details

Published by

SammyEnigma on GitHub

Code credit

Greeffer, as written in the script's header

Type

Strategy, Pine Script v4

Draws

On the price chart

Category

Oscillators & momentum, Volatility & bands

Markets

Crypto

Timeframes

M15-H1

Risk Notes

  • The strategy can add several entries in the same direction
  • The strategy enters trades without a stop loss

Settings

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

SettingTypeDefaultVariable
Sellint80sell
Buyint20buy
Lengthint14length
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

330 stars

Alert BB + RSI [Alorse] is a multi-symbol mean-reversion strategy designed for cryptocurrency trading. It evaluates Bollinger Bands and the Relative Strength Index (RSI) across up to 20 user-defined ticker symbols simultaneously. The strategy enters long posit

Strategy v4 Oscillators & momentumVolatility & bands
Updated 2 months ago · None stated GitHub repository of Alert BB + RSI [Alorse]
106 stars

This strategy identifies trend-following entries using a triple exponential moving average alignment and ATR-based exits on the main price chart. Long signals trigger when the fast EMA is above the medium EMA and medium is above slow, accompanied by a close ab

Strategy v4 Moving averagesVolatility & bands Repaints
Updated 2 years ago · GPL-3.0 GitHub repository of 3 EMA + Stochastic RSI + ATR
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
104 stars

This strategy combines Bollinger Bands with a short RSI to fade moves that leave the bands and then return. A long requires the prior bar below the lower band and oversold, then a close back inside the band while RSI is between 30 and 50. Shorts mirror that at

Strategy v5 Oscillators & momentumVolatility & bands
Updated 3 years ago · MIT GitHub repository of Bollinger Bands and RSI Strategy

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