1Copy the scriptPress Copy script above, or the copy button on the code below.
2Open the Pine EditorOpen a TradingView chart and choose Pine Editor at the bottom of the screen.
3Paste over the templateCreate a new strategy, select all of the template text and paste. Press Save and give it a name.
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.
The inputs you can change from the gear icon on the chart. Defaults are the author's.
Setting
Type
Default
Variable
Contribution (USD)
int
500
contribution
Bollinger (Period)
int
20
length
Deviations (Float)
float
2.0
mult
RSI (Period)
int
14
rsi_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.
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
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
This strategy calculates a smoothed Relative Strength Index and plots self-adjusting linear regression bands with overbought and oversold boundaries in a separate pane. It enters long positions through dollar-cost averaging orders scaled across market phases a
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
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
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