Strategy · Pine Script v4 · Own pane

Greeffer BB Strategy

by SammyEnigma· code credited to Greeffer

Greeffer BB Strategy is a volatility-based mean reversion system that calculates Bollinger Bands using price and standard deviation.

View on GitHub

Repaints

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

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

greeffer-bb-strategy-0.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
// 04-11-2020: 5.7% profit in backtests trading BTCUSDTPERP on 1m time frame (no leverage)

strategy("Greeffer BB Strategy", "Greeffer", false, format=format.price, scale=scale.right, precision=2, pyramiding=11, default_qty_type=strategy.percent_of_equity, default_qty_value=11, initial_capital=100000, currency=currency.USD, commission_type=strategy.commission.percent, commission_value=0.075, process_orders_on_close=true)

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

if (crossover(source, upper))
    strategy.entry("sell", strategy.short, comment="sell", when = rsi(close, 14) > 70)
    strategy.close("sell", when= rsi(close, 14) < 30, qty_percent = 100, comment = "close sell 50%")
if (crossunder(source, lower))
    strategy.entry("buy", strategy.long, oca_name="BollingerBands", comment="buy", when = rsi(close, 14) > 30)
    strategy.close("buy", when = rsi(close, 14) > 70, qty_percent = 100, comment = "close buy 50%")
//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 generates long and short signals when price crosses the upper and lower bands respectively. Entries are filtered with RSI(14) conditions and exits occur when RSI crosses opposite thresholds. The strategy supports pyramiding with equity-based position sizing and commissions. Equity curve is plotted in a separate pane. It repaints on the live bar and has no stop loss.

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

Volatility & bands, Oscillators & momentum, Mean reversion

Markets

Crypto

Timeframes

M1-M5

Risk Notes

  • Signals can change on the live bar or after it closes (repainting)
  • 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
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

This strategy combines Larry Williams' Vix Fix synthetic volatility indicator with Bollinger Bands. It calculates standard and inverted Williams Vix Fix metrics, displaying them as histogram columns with standard deviation bands in a separate pane. Long entrie

Strategy v4 Volatility & bandsOscillators & momentum
Updated 2 months ago · None stated GitHub repository of Williams Vix Fix Strategy [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

Alpy Vix

by avatar-lavventura
2 stars

This strategy plots the Williams Vix Fix indicator as a histogram in a separate pane to detect potential trend reversals. It calculates the Vix Fix value using a lookback period and standard deviation bands derived from Bollinger Bands on the Vix Fix. Multiple

Strategy v4 Oscillators & momentumVolatility & bands Repaints
Updated 7 months ago · None stated GitHub repository of Alpy Vix

This strategy calculates intraday volatility mean reversion using session VWAP standard deviation bands, RSI overbought and oversold levels, and candle wick exhaustion ratios. It enters trades when price reaches statistical extremes filtered by RSI and wick co

Strategy v6 Mean reversionVolatility & bands
Updated 7 months ago · MIT GitHub repository of Intraday Volatility Reversion Z-Score

RSI with Bollinger Bands

by pineforge-4pass
1 stars

Calculates the Relative Strength Index (RSI) and wraps Bollinger Bands directly around the RSI series rather than price. It enters long positions when the RSI drops below its lower band and hooks back upward, and enters short positions when the RSI exceeds the

Strategy v6 Oscillators & momentumVolatility & bands
Updated 5 days ago · Apache-2.0 GitHub repository of RSI with Bollinger Bands

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