//@version=5
strategy("Bollinger Bands Strategy", overlay=true)
length = input.int(20, 'Len SMA', minval=1)
rsiLength = input.int(14, 'Len RSI', minval=1)
mult = input.float(2.0, 'Mult', minval=0.001, maxval=50)
source = close
basis = ta.sma(source, length)
dev = mult * ta.stdev(source, length)
upper = basis + dev
lower = basis - dev
rsi = ta.rsi(source, rsiLength)
plot(basis, "Basis", color=#FF6D00)
p1 = plot(upper, "Upper", color=#2962FF)
p2 = plot(lower, "Lower", color=#2962FF)
fill(p1, p2, title = "Background", color=color.rgb(33, 150, 243, 95))
isLong = rsi > 25 and source <= lower and strategy.position_size == 0
isExit = rsi > 70 and source > basis and strategy.position_size != 0
strategy.entry("BBandLE", strategy.long, when=isLong, comment="BBandLE")
strategy.close(id="BBandLE", when=isExit, comment="BBandLE Exit")
// Another version
// if (ta.crossover(source, lower))
// strategy.entry("BBandLE", strategy.long, stop=lower, oca_name="BollingerBands", oca_type=strategy.oca.cancel, comment="BBandLE")
// else
// strategy.cancel(id="BBandLE")
// if (ta.crossunder(source, upper) && rsi > 70)
// strategy.entry("BBandSE", strategy.short, stop=upper, oca_name="BollingerBands", oca_type=strategy.oca.cancel, comment="BBandSE")
// else
// strategy.cancel(id="BBandSE")
//plot(strategy.equity, title="equity", color=color.red, linewidth=2, style=plot.style_areabr)
Overview
Bollinger Bands Strategy also calculates RSI. It opens one long trade when RSI is above 25, price is at or below the lower band, and no position is open. It closes that long when RSI is above 70 and price is above the basis. SMA length, RSI length, and band multiplier are adjustable. There is no stop loss and no short entry in the active rules.
The inputs you can change from the gear icon on the chart. Defaults are the author's.
Setting
Type
Default
Variable
Len SMA
int
20
length
Len RSI
int
14
rsiLength
Mult
float
2.0
mult
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 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
This strategy plots on the price chart and combines up to seven optional modules that vote for long or short conditions. The modules use a 20-period simple moving average, a five-period RSI, Bollinger Band squeezes, a simplified prior-bar break, stacked expone
BB RSI Strategy combines Bollinger Bands, RSI, and multiple simple moving averages directly on the main price chart. It enters long positions when price drops below the lower Bollinger Band while RSI is below a set limit, and enters short positions when price
This strategy executes mean-reversion trades by combining RSI momentum, Bollinger Bands volatility, dynamic ATR stops, and Exponential Moving Averages for trend filtering. It seeks entry opportunities when price reaches extreme Bollinger Band boundaries alongs
Calculates a reversal confidence score combining Bollinger Band overextension, RSI exhaustion, and price distance from a exponential moving average. The strategy overlays VWAP, EMA, and Bollinger Bands directly on the price chart. Long signals trigger when pri
This strategy plots an anchored volume-weighted average price and two standard-deviation bands on the price chart. It buys dips below the inner band when a short RSI is oversold and an optional EMA trend filter agrees, and it can sell rallies above the inner b