Strategy · Pine Script v4 · On the chart

VOL/BBW/RSI/15 Strategy

by SammyEnigma· code credited to Greeffer

This strategy overlays Bollinger Bands on the price chart and trades a long squeeze setup.

View on GitHub

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

86 lines of Pine Script v4 from vol-bbw-rsi-15m.pine, published under MPL-2.0 (file header). Keep the author's credit and licence lines when you reuse it.

vol-bbw-rsi-15m.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
// Trading BTCUSDT 15 minute time frame on Binance Spot Exchange yeiled 547% return in backtests

//@version=4

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

// S t r a t e g y
strategy("VOL/BBW/RSI/15 Strategy", "VOL/BBW/RSI/15 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, max_bars_back=300)
// strategy(title, shorttitle, overlay, format, precision, scale, pyramiding, calc_on_order_fills, calc_on_every_tick, max_bars_back, backtest_fill_limits_assumption, default_qty_type, default_qty_value, initial_capital, currency, slippage, commission_type, commission_value, process_orders_on_close, close_entries_rule)

// V a r i a b l e s
source = input(close, title="RSI Source")
sell = input(title="Sell", defval=75, minval=0, maxval=100)
buy = input(title="Buy", defval=25, minval=0, maxval=100)
length = input(title="Length", defval=14, minval=1, maxval=500)
volMA = sma(volume,7)
showMA = input(true)


// V o l u m e
barColorsOnPrevClose = input(title="Color bars based on previous close", type=input.bool, defval=false)
palette = barColorsOnPrevClose ? close[1] > close ? color.red : color.green : open > close ? color.red : color.green
plot(volume, color = palette, style=plot.style_columns, title="Volume", display=display.none)
plot(showMA ? sma(volume,20) : na, style=plot.style_area, color=color.blue, display=display.none)

// S t o c h   R S I 
smoothK = input(3, minval=1) // <-----------------------------------------------
smoothD = input(3, minval=1) // <-----------------------------------------------
lengthRSI = input(14, minval=1)
lengthStoch = input(14, minval=1)

rsi1 = rsi(source, lengthRSI)
k = sma(stoch(rsi1, rsi1, rsi1, lengthStoch), smoothK)
d = sma(k, smoothD)
//plot(k, color=color.blue)
//plot(d, color=color.orange)
//h0 = hline(80)
//h1 = hline(20)
//fill(h0, h1, color=color.purple, transp=80, display=display.none)

// B o l l i n g e r   B a n d s 
[middle, upper, lower] = bb(source, length, 2.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.2)
plot(bbW, title="bbWidth", color=color.orange, display=display.none)

//  C o n d i t i o n s
buyCondition = bbW<0.022 and volume>=volMA
//buyCondition = crossover(k, d) and k<25
//buyCondition = K>D and rsi<60 and bbw < 0.022
sellCondition = crossover(close, upper)
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=strategy.position_size > 0)
    // strategy.order("short", strategy.short, qty=20, stop=upper, oca_name="long0", oca_type=strategy.oca.reduce, when=rsi1>=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}}"}')
//alertcondition(crossunder(myRsi, buy) and crossunder(close, lower), title='Buy', message='{"direction":"buy","ticker":"{{ticker}}","frame":"1minute","close":"{{close}}","time":"{{time}}"}')

// S E L L
//alertcondition(sellCondition, title='Sell', message='{"direction":"sell","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}}"}')

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

Overview

VOL/BBW/RSI/15 Strategy enters long when band width is below 0.022 and volume is at least the seven-bar average, using a stop order at the lower band. It places a short order when close crosses above the upper band and closes the long when price crosses under the middle band while width is above 0.05. Stochastic RSI is calculated but not used in the active conditions. Settings change the RSI source, band length, and volume bar coloring. It allows pyramiding and has no default protective stop.

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

Volatility & bands, Volume, Breakout

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
RSI Sourcesourceclosesource
Sellint75sell
Buyint25buy
Lengthint14length
showMAbooltrueshowMA
Color bars based on previous closeboolfalsebarColorsOnPrevClose
smoothKint3smoothK
smoothDint3smoothD
lengthRSIint14lengthRSI
lengthStochint14lengthStoch
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

BB and KC Strategy

by hasnocool
106 stars

This strategy identifies breakout momentum by combining Bollinger Bands and Keltner Channels with volume confirmation. It opens long positions when the upper Keltner Channel crosses above the upper Bollinger Band and volume exceeds its moving average. Converse

Strategy v5 Volatility & bandsBreakout
Updated 2 years ago · GPL-3.0 GitHub repository of BB and KC Strategy

VWAP + Volume

by muammeryldrm42
7 stars

The VWAP + Volume strategy trades crossovers of the Volume Weighted Average Price confirmed by volume surges. It enters long or short positions when the closing price crosses above or below the VWAP line while volume exceeds its 20-period simple moving average

Strategy v5 VolumeBreakout
Updated 3 months ago · MIT GitHub repository of VWAP + Volume
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
218 stars

This strategy detects price breakouts above rolling highest highs or below lowest lows over a customizable lookback period. It includes optional volume spike and ATR volatility threshold filters, along with bar confirmation rules. Positions are taken upon conf

Strategy v6 BreakoutVolatility & bands
Updated 3 months ago · None stated GitHub repository of Breakout Strategy Template

Bollinger Breakout

by hackingthemarkets
189 stars

This price-chart strategy plots a simple moving average and upper and lower bands built from the standard deviation of close, scaled by separate offset inputs. It enters a fixed quantity long when close crosses above the upper band and a fixed quantity short w

Strategy v4 Volatility & bandsBreakout
Updated 3 years ago · None stated GitHub repository of Bollinger Breakout

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