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
116 lines of Pine Script v5 from PineScript/Stg_ex_BB.pine, published under MPL-2.0 (file header). Keep the author's credit and licence lines when you reuse it.
Bollinger Bands Strategy generates signals from band touches and an exit SMA of 110 bars. Risk management limits losses to 6 percent of trade value. Money management scales position size by a fixed ratio of 400 and adds 200 per increment. It operates in a backtest window from 2017 to 2024.
The inputs you can change from the gear icon on the chart. Defaults are the author's.
Setting
Type
Default
Variable
BB Length
int
120
bbLength
Standard Deviation Multipler
float
2
mult
SMA Exit Signal Length
int
110
smaLength
Max Risk per trade (in %)
float
6
slMax
Fixed Ratio Value ($)
int
400
fixedRatio
Increasing Order Amount ($)
int
200
increasingOrderAmount
Start Date
time
timestamp("1 Jan 2017 00:00:00")
startDate
End Date
time
timestamp("1 July 2024 00:00:00")
endDate
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