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
187 lines of Pine Script v5 from Bollinger Bands - Breakout Strategy.pine, published under GPL-3.0. Keep the author's credit and licence lines when you reuse it.
Bollinger Bands - Breakout Strategy features optional trend filters using various moving average types, a volatility filter based on standard deviation relative to its moving average, and a daily rate-of-change filter. Users can restrict trade directions or let auto-detection select long and short modes based on symbol details. Exits are managed via customizable percentage-based take profit, stop loss, trailing stops, and trailing offsets.
Bollinger Bands breakout signal generation
Configurable trend filter with multiple moving average types
Volatility filter based on standard deviation
Daily rate-of-change filter with non-repainting security calls
Percentage-based stop loss, take profit, and trailing stops
The inputs you can change from the gear icon on the chart. Defaults are the author's.
Setting
Type
Default
Variable
Length
int
15
bbLengthInput
StdDev
float
2.0
bbDevInput
Above/Below
bool
false
trendFilterInput
trendFilterPeriodInput
int
223
trendFilterPeriodInput
trendFilterType
string
EMA
trendFilterType
StdDev
bool
true
volatilityFilterInput
volatilityFilterStDevLength
int
15
volatilityFilterStDevLength
>MA
int
15
volatilityStDevMaLength
roc_enable
bool
false
roc_enable
Treshold
float
1
roc_threshold
Trade
string
Auto
tradeDirectionInput
Start
time
timestamp("2017-01-01")
start
Show all 24 settings
Setting
Type
Default
Variable
End
time
timestamp("2050-01-01")
finish
TS
float
2
xl_ts_percent
TO
float
0.5
xl_to_percent
SL
float
2
xl_sl_percent
TP
float
9
xl_tp_percent
TS
float
2
xs_ts_percent
TO
float
0.5
xs_to_percent
SL
float
2
xs_sl_percent
TP
float
9
xs_tp_percent
Max Intraday Loss (Percent)
int
10
max_intraday_loss
Precision
int
2
results_prec
Dark Mode
bool
true
results_dark
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 trades long breakouts of a fast and a slow moving average on the price chart. It opens a long position when price crosses above either average, using a percentage of equity as size. It reduces the position by a set share when the high reaches the
This strategy plots Donchian channels, trailing stops, and profit targets directly on the price chart. It enters breakout trades using a 55-bar Donchian channel and sizes positions according to an ATR-based risk percentage per unit. The system adds units as pr
This strategy combines channel breakout concepts with an ATR-ADX volatility trailing framework and multi-timeframe moving averages. It evaluates trend conditions using configurable moving average types, including SMA, EMA, Hull MA, and Tilson T3, paired with d
This strategy executes trend-following trades based on Bollinger Band breakouts confirmed by a long-term moving average filter. A long position opens when the price crosses above the upper Bollinger Band, provided the band spread meets a minimum threshold and
The Keltner Channel Strategy is a breakout system plotted directly on the main price chart. It calculates upper and lower channel bands around an exponential or simple moving average using ATR, True Range, or bar range multiplied by a specified factor. A long
This strategy combines Bollinger Bands and Bollinger Band Width to trigger breakout trades during periods of low volatility. It opens long positions when price crosses above the upper band while band width is below its 100-period moving average, and opens shor