The script plots the SMA middle band along with Bollinger upper and lower bands with two standard deviations, filling the area between them on the price chart.
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
20 lines of Pine Script v4 from Bollinger bubble - Stock Edition.pine, published under GPL-3.0. Keep the author's credit and licence lines when you reuse it.
Bollinger bubble - Stock Edition.pine
//@version=4
// Initial settings
strategy("Bulle de bollinger", overlay = true, currency = currency.EUR, initial_capital = 10000, default_qty_type = strategy.percent_of_equity, default_qty_value = 100, commission_type = strategy.commission.percent, commission_value = 0)
// Parameter Settings
mdl = sma(close, 20)
dev = stdev(close, 20)
upr = mdl + 2*dev
lwr = mdl - 2*dev
// Plot
plot(mdl, color = color.red) // Plot moving average
p1 = plot(upr, color = color.green) // Plot Upper_band
p2 = plot(lwr, color = color.green) // Plot lower band
fill(p1, p2, color = color.blue) // Fill transparant color between the 2 plots
// Strategy entry & close
if open[1] < lwr[1] and close[0] > low[0] // Previous price lower than lower band and current close is higher than lower band
stop_level = lowest(100)
profit_level = highest(20)
strategy.entry(id = 'bb_buy', long = true)
strategy.exit("TP/SL", "bb_buy", stop=stop_level, limit=profit_level)
Expand (25 lines)
Overview
Bulle de Bollinger signals long entries on a close crossing above the lower band after the previous bar was below it, using a stop loss at the lowest price over the last 100 bars and a take profit at the highest price over the last 20 bars. Position size is 100 percent of equity with zero commission. The strategy draws directly on the price chart for stock data and works on any timeframe.
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 plots Bollinger Bands on the price chart with adjustable length, standard deviation, and offset. It defines buy and sell zones using candle size percentage and body size thresholds. Long positions enter when the lower zone is breached without con
This overlay strategy offers two selectable entry modes: a Bollinger squeeze on typical price and a simple moving-average cross. It filters trades by weekday, session, date range, and an optional news window, and can restrict direction or invert the side. Risk
This overlay strategy targets one-minute ES futures and plots volume-weighted moving-average bands from the open, scaled by a standard-deviation multiple, plus a slower band from ten-minute opens. A higher-timeframe exponential moving average can filter trades
STRG-BBForce is a Bollinger Bands trend-following strategy. It calculates standard Bollinger Bands and tracks directional alignment across the upper, lower, and basis lines. When all three lines slope upward, it opens a long position and closes short positions
The Mean Reversion Strategy Template calculates a baseline mean using SMA, EMA, or VWAP alongside upper and lower deviation bands based on standard deviation, ATR, or percentage offsets. It generates long and short entries when price touches, bounces from, or
This price-chart strategy plots a simple moving average and upper and lower bands built from the standard deviation of close, scaled by separate offset inputs. It enters a fixed quantity long when close crosses above the upper band and a fixed quantity short w