Strategy · Pine Script v4 · Own pane

RSI/BB 1minute Study

by SammyEnigma· code credited to Greeffer

This 1-minute strategy combines the Relative Strength Index (RSI), Bollinger Bands, and Bollinger Band Width to trigger trades.

View on GitHub

GitHub stars18on the repository
Pine versionv4older, still runs
Lines of code59
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

59 lines of Pine Script v4 from rsi-bb-1min-v1.pine, published under MPL-2.0 (file header). Keep the author's credit and licence lines when you reuse it.

rsi-bb-1min-v1.pine
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © Greeffer

//@version=4
//study("RSI/BB 1minute Study", shorttitle="BBW/RSI/1m", precision=5)
strategy("RSI/BB 1minute Study", "BBW/RSI/1m", false, format=format.inherit, 
     scale=scale.right, precision=5, pyramiding=20, default_qty_type=strategy.percent_of_equity,
     default_qty_value=100, 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)

// R S I
source = close
sell = input(title="Sell", defval=75, minval=0, maxval=100)
buy = input(title="Buy", defval=34, minval=0, maxval=100)
length = input(title="Length", defval=14, minval=1, maxval=500)
myRsi = rsi(source, length)
plot(myRsi, title="myRsi", color=color.blue, linewidth=2, style=plot.style_line, transp=70)
hline(buy, title='buy', color=color.red, linestyle=hline.style_dotted, linewidth=1)
hline(sell, title='sell', color=color.red, linestyle=hline.style_dotted, linewidth=1)

// B o l i n g e r   B a n d s 
//bBands = bb(close, length, mult)
[middle, upper, lower] = bb(source, length, 2)
plot(middle, title="middle", color=color.red, display=display.none)
plot(upper, title="upper", color=color.green, display=display.none)
plot(lower, title="lower", color=color.green, display=display.none)

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

// S t r a t e g i e s

if (crossunder(source, lower) and crossunder(myRsi, buy))
    strategy.entry("long0", strategy.long,stop=strategy.position_avg_price +
         strategy.position_avg_price*0.1, oca_name="long0",
         oca_type=strategy.oca.reduce)
    strategy.exit("longo", oca_name="long0", qty_percent=100, stop=strategy.position_avg_price +
         strategy.position_avg_price*0.1, trail_price=middle, trail_offset=2)
    //strategy.close(id, when, comment, qty, qty_percent) 
    //strategy.close("short0", when=source<lower, qty_percent=100)

if(bbWidth <= 0.00260)
    strategy.entry("bbWidth0", strategy.long, stop=strategy.position_avg_price +
         strategy.position_avg_price*0.1, oca_name="long0", oca_type=strategy.oca.reduce)
    strategy.exit("bbWidth0", oca_name="long0", qty_percent=100, stop=strategy.position_avg_price +
         strategy.position_avg_price*0.1, trail_price=middle, trail_offset=5, when=crossover(myRsi, sell))
    
if (crossover(source, upper)and crossover(myRsi, sell))
    strategy.entry("short0", strategy.short, stop=strategy.position_avg_price +
         strategy.position_avg_price*0.1, oca_name="long0", oca_type=strategy.oca.reduce)
    strategy.exit("short0", oca_name="long0", qty_percent=100, stop=strategy.position_avg_price +
         strategy.position_avg_price*0.1, trail_price=middle, trail_offset=2)
    //strategy.close("long0",when=source>upper, qty_percent=100)

// A l e r t c o n d i t i o n s 
//alertcondition(crossunder(myRsi, buy) and crossunder(close, lower), title='Buy', message='{"direction":"buy","ticker":"{{ticker}}","frame":"1minute","close":"{{close}}","time":"{{time}}"}')
//alertcondition(crossover(myRsi, sell) and crossover(close, upper), title='Sell', message='{"direction":"sell","ticker":"{{ticker}}","frame":"1minute","close":"{{close}}","time":"{{time}}"}')

Overview

RSI/BB 1minute Study plots the RSI curve and custom buy or sell threshold lines in a separate pane. Long entries trigger when price and RSI drop below the lower Bollinger Band and buy threshold, or when Bollinger Band Width contracts below a tight limit. Short entries trigger when price and RSI cross above the upper band and sell threshold. Inputs allow customizing the RSI length and threshold levels.

Details

Published by

SammyEnigma on GitHub

Code credit

Greeffer, as written in the script's header

Type

Strategy, Pine Script v4

Draws

Separate pane below the chart

Category

Oscillators & momentum, Volatility & bands, Scalping

Markets

Any symbol

Timeframes

M1-M5

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
Sellint75sell
Buyint34buy
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

5 Minute Scalp

by hasnocool
106 stars

This strategy overlays three exponential moving averages on the price chart, with periods of 9, 50, and 200. It calculates a MACD histogram from a 1-minute timeframe, applies Bollinger Bands to the histogram, and tracks two RSI oscillators of different lengths

Strategy v5 ScalpingMoving averages
Updated 2 years ago · GPL-3.0 GitHub repository of 5 Minute Scalp
27 stars

LuxAlgo Hybrid Gold Scalper is a price-chart strategy aimed at gold. It stacks a fast, slow, trend and 200-period bias EMA to mark trend direction, then filters strength with RSI, ADX and an intraday VWAP. Swing highs and lows are marked from pivot length. Set

Strategy v5 TrendOscillators & momentum
Updated 5 months ago · None stated GitHub repository of LuxAlgo Hybrid Gold Scalper

This trend-following scalping strategy combines a moving average trend filter with the Absolute Strength Histogram indicator. It opens long positions when price is above a selectable baseline moving average and the histogram signals bullish momentum, and short

Strategy v5 TrendOscillators & momentum
Updated 1 year ago · None stated GitHub repository of Ruckard TradingZone Absolute Strength Histogram ATR

VAMO Crossover Strategy

by TPTBusiness
4 stars

The VAMO Crossover Strategy is a scalping system that combines momentum and volatility into a Volatility-Adjusted Momentum Oscillator (VAMO). It calculates momentum using Rate of Change divided by ATR and generates trade signals when VAMO crosses its EMA signa

Strategy v6 Oscillators & momentumVolatility & bands
Updated 12 months ago · MIT GitHub repository of VAMO Crossover Strategy

Box Scalper

by wynnforthework
2 stars

This strategy draws on the price chart and combines a momentum zigzag, a custom QQE built from RSI, ADX directional strength, an SSL filter, and a coefficient-of-variation weighted average. Box period, deviation, and threshold inputs set the box filter, while

Strategy v5 Oscillators & momentumTrend
Updated 1 year ago · None stated GitHub repository of Box Scalper

Hari Sweep Scalper

by godlesscherry
2 stars

This overlay strategy looks for Bollinger Band and optional fractal sweeps only in the Supertrend direction, with an optional MACD filter. Long and short setups expire after a set number of bars, and the first bar after a Supertrend flip is ignored. It enters

Strategy v6 TrendVolatility & bands
Updated 7 months ago · None stated GitHub repository of Hari Sweep Scalper

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