Strategy · Pine Script v4 · Own pane

Bollinger DCA v1

by hasnocool

This strategy calculates Bollinger Bands and RSI to trigger dollar-cost averaging buy orders.

View on GitHub

GitHub stars106on the repository
Pine versionv4older, still runs
Lines of code42
Settings4inputs
LicenceGPL-3.0
Last update2 years ago18 Sep 2024

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

42 lines of Pine Script v4 from Bollinger DCA v1.pine, published under GPL-3.0. Keep the author's credit and licence lines when you reuse it.

Bollinger DCA v1.pine
//@version=4
strategy("Bollinger DCA v1", overlay=false)
//user inputs
contribution = input(title="Contribution (USD)",type=input.integer,minval=1,maxval=1000000,step=1,defval=500,confirm=false)
length = input(title="Bollinger (Period)", defval=20, step=1, minval=1)
mult = input(title="Deviations (Float)", defval=2.0, step=0.001, minval=0.001, maxval=50)
rsi_period = input(title="RSI (Period)", defval=14, step=1, minval=1)
//compute bollinger bands
source = close
basis = sma(source, length)
dev = mult * stdev(source, length)
upper = basis + dev
lower = basis - dev
//compute moving averages
ma50 = sma(close,50)
ma100 = sma(close,100)
ma150 = sma(close,150)
ma200 = sma(close,200)
//up_trend = ma50 > ma100 and ma100 > ma150 and ma150 > ma200
//dn_trend = ma50 < ma100 and ma100 < ma150 and ma150 < ma200
//compute rsi
strength = rsi(close, rsi_period)
//plot indicators
//p1 = plot(upper, color=color.gray)
//p2 = plot(lower, color=color.gray)
//fill(p1, p2)
//p3 = plot(ma50, color=color.red)
//p4 = plot(ma100, color=color.blue)
//p5 = plot(ma150, color=color.green)
//p6 = plot(ma200, color=color.orange)
//units to buy
units = contribution / close
//long signal
if (close < lower and strength < 50)
    strategy.order("Long", strategy.long, units)
//close long signal
//if (close > upper and strength > 50 and strategy.position_size > 0)
    //strategy.order("Close Long", strategy.short, units)
    
//plot strategy equity
plot(strategy.openprofit, color=color.blue, linewidth=2, title="Open Profit")
Expand (49 lines)

Overview

Bollinger DCA v1 enters long positions whenever the closing price dips below the lower Bollinger Band while the RSI is below 50. Order units are calculated dynamically based on a fixed USD contribution input divided by the current close price. The script plots unrealized open profit in a separate pane. Notably, all exit signals and stop loss rules are disabled or commented out, leaving entered positions open without profit targets or protective stops.

Details

Published by

hasnocool on GitHub

Type

Strategy, Pine Script v4

Draws

Separate pane below the chart

Category

Volatility & bands, Oscillators & momentum, Mean reversion

Markets

Crypto

Timeframes

Any timeframe

Risk Notes

  • The strategy enters trades without a stop loss

Topics

analysisbtcusdtcryptocurrencydatapandaspythonsimulationtradingtradingview

Settings

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

SettingTypeDefaultVariable
Contribution (USD)int500contribution
Bollinger (Period)int20length
Deviations (Float)float2.0mult
RSI (Period)int14rsi_period
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]

Greeffer BB Strategy

by SammyEnigma
18 stars

This strategy fades Bollinger Band extremes using the close. It enters short when price crosses above the upper band and the 14-period RSI is above 70, and enters long when price crosses below the lower band and RSI is below 30. It closes half of an open short

Strategy v4 Volatility & bandsOscillators & momentum
Updated 6 years ago · None stated GitHub repository of Greeffer BB Strategy
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
13 stars

This strategy overlays the price chart to trade DAX futures during European market hours. It calculates exponential and simple moving averages, RSI, MACD, Bollinger Bands, ATR, and realized volatility to simulate VIX levels. Trades execute when session time fi

Strategy v5 Sessions & timeOscillators & momentum
Updated 8 months ago · Custom licence GitHub repository of ClaudeHedge - DAX Session Strategy

Calculates a combination of the Relative Strength Index, MACD histogram, and Bollinger Bands contraction to identify long trade entries. The strategy signals a long position on a bullish bar when the MACD histogram turns upward while negative, RSI remains belo

Strategy v4 Oscillators & momentumVolatility & bands
Updated 3 years ago · Apache-2.0 GitHub repository of RSI + MACD + BB Long Strategy (Not Good)

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