Strategy · Pine Script v4 · Own pane

Greeffer BB Strategy

by SammyEnigma· code credited to Greeffer

This strategy combines Bollinger Bands, Bollinger Band Width, and the Relative Strength Index (RSI) for mean-reversion trades.

View on GitHub

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

38 lines of Pine Script v4 from greeffer-bb-strategy-4.pine, published under MPL-2.0 (file header). Keep the author's credit and licence lines when you reuse it.

greeffer-bb-strategy-4.pine
//@version=4
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © Greeffer
//
strategy("Greeffer BB Strategy", "Greeffer", false, format=format.price, scale=scale.right, precision=2, pyramiding=10, default_qty_type=strategy.percent_of_equity, default_qty_value=20, initial_capital=1000, currency=currency.USD, commission_type=strategy.commission.percent, commission_value=0.075, process_orders_on_close=true)
source = close
length = input(20, minval=1)
rsiLength = input(14, minval=1)
mult = input(1.9, minval=0.001, maxval=50)
basis = sma(source, length)
dev = mult * stdev(source, length)
upper = basis + dev
lower = basis - dev

x = bbw(source, length, 2.1)
plot(bbw(source, length, 2.5), title="bb width", color=color.yellow)
if (x<0.01)
    strategy.entry("buy", strategy.long, comment="buyx", when=rsi(close, rsiLength)<30)
    //strategy.close("buy", when=rsi(close, 14)>80, comment = "close sell")

if (crossover(source, upper))
    strategy.entry("sell", strategy.short, comment="sell", when=rsi(close, rsiLength)>80)
    strategy.close("sell", when=crossunder(source, lower), comment = "close sell")

if (crossunder(source, lower))
    strategy.entry("buy", strategy.long, comment="buy", when=rsi(close, rsiLength)>30)
    strategy.close("buy", when=crossover(source, upper), comment = "close buy")


//plot(bbw(close, 20, 2), color=color.yellow)


//bb(series, length, mult)

//strategy.risk.max_drawdown(3, strategy.percent_of_equity) // set maximum drawdown to 50% of maximum equity
//strategy.close_all(when= , comment="close all")

// plot(strategy.equity, title="equity", color=color.red, linewidth=2, style=plot.style_areabr)

Overview

Greeffer BB Strategy enters long when price crosses below the lower band with oversold RSI, or when band width contracts under low volatility. Short entries occur when price crosses above the upper band with overbought RSI. Long trades exit upon upper band crossovers, while short trades close on lower band crossunders. Plotted in a separate pane as a yellow line, it tracks band width. Inputs adjust band length, multiplier, and RSI length. Pyramiding allows up to ten entries without hard stop-loss 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

Mean reversion, Oscillators & momentum, Volatility & bands, Moving averages

Markets

Any symbol

Timeframes

Any timeframe

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
lengthint20length
rsiLengthint14rsiLength
multfloat1.9mult
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

This mean-reversion strategy combines multi-timeframe exponential moving averages, Bollinger Bands, and the Relative Strength Index. It generates long and optional short trade signals when price interacts with the Bollinger Bands alongside RSI threshold confir

Strategy v5 Mean reversionMoving averages
Updated 2 months ago · None stated GitHub repository of MEMA + BB + RSI [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

EMA Ribbon MACD

by iamrichardD
57 stars

This strategy combines an EMA ribbon with MACD confirmation and plots in a separate pane. It enters when ribbon alignment, optional MACD zero or signal crosses, volume, smart-money, and multi-timeframe filters agree, then exits with percentage stop loss and ta

Strategy v6 TrendMoving averages
Updated 1 year ago · Apache-2.0 GitHub repository of EMA Ribbon MACD
25 stars

This Pine Script strategy calculates Bayesian probabilities of price breaking up or down relative to Bollinger Bands and a Simple Moving Average. It plots these breakout and breakdown probability lines as oscillators in a separate pane. Long entries trigger wh

Strategy v4 Oscillators & momentumVolatility & bands
Updated 6 years ago · None stated GitHub repository of Bayesian BBSMA Oscillator Strategy

AwesomeADX

by koradiyakaushal
12 stars

AwesomeADX is a Pine Script v4 strategy that combines an Awesome Oscillator, ADX directional movement, and Bollinger percent B with an optional four-length moving-average trend filter. It sizes each position as a percentage of equity and can limit trades to a

Strategy v4 Oscillators & momentumMoving averages
Updated 5 years ago · MIT GitHub repository of AwesomeADX

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