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
49 lines of Pine Script v4 from Bolinger strategy v1 open.pine, published under GPL-3.0. Keep the author's credit and licence lines when you reuse it.
Bolinger strategy v1 open.pine
//@version=4
//study(title = "Bolinger strategy", overlay=true)
strategy("Bolinger strategy",currency="SEK",default_qty_value=10000,default_qty_type=strategy.cash,max_bars_back=50)
len = 5
src = close
up = rma(max(change(src), 0), len)
down = rma(-min(change(src), 0), len)
rsi = down == 0 ? 100 : up == 0 ? 0 : 100 - (100 / (1 + up / down))
bbw3level = input(15, title="bbw3")
bbr3level = input(0.45, title="bbr3level")
bbrlower = input(0.4480, title="bbrlower")
bbrhigher = input(0.4560, title="bbrhigher")
sincelowestmin = input(7, title="sincelowestmin")
sincelowestmax = input(57, title="sincelowestmax")
length = input(20, minval=1)
mult = 20
src3 = close[3]
basis3 = sma(src3, length)
dev3 = mult * stdev(src3, length)
upper3 = basis3 + dev3
lower3 = basis3 - dev3
bbr3 = (src3 - lower3)/(upper3 - lower3)
bbw3 = (upper3-lower3)/basis3*100
basis = sma(src, length)
dev = mult * stdev(src, length)
upper = basis + dev
lower = basis - dev
bbr = (src - lower)/(upper - lower)
bbw = (upper-lower)/basis*100
criteriamet = 0
crossUnderB0 = crossunder(bbr,0)
since_x_under = barssince(crossUnderB0)
sincelowest = barssince(close[6] > close[3] and close[5] > close[3] and close[4] > close[3] and close[2] > close[3] and close[1] > close[3] and close > close[3] and bbw3 > bbw3level and bbr3 < bbr3level) // and bbr3 < 0
if sincelowest > sincelowestmin and sincelowest < sincelowestmax and bbr > bbrlower and bbr < bbrhigher
criteriamet := 1
else
criteriamet := 0
//plot (criteriamet)
//exit
exitmet = 0
if rsi > 70
exitmet := 1
else
exitmet := 0
if criteriamet == 1
strategy.entry("long", strategy.long)
if exitmet == 1
strategy.close("long")
Expand (64 lines)
Overview
Bolinger strategy opens a long when a local low around that earlier bar falls inside a bar-count window and current percent B stays in a narrow range. It closes the long when RSI exceeds 70. Settings change bandwidth and percent-B thresholds, the timing window, and average length; the band multiplier stays fixed at 20. There is no stop loss. Size defaults to cash in SEK, and the strategy runs in a separate pane.
The inputs you can change from the gear icon on the chart. Defaults are the author's.
Setting
Type
Default
Variable
bbw3
int
15
bbw3level
bbr3level
float
0.45
bbr3level
bbrlower
float
0.4480
bbrlower
bbrhigher
float
0.4560
bbrhigher
sincelowestmin
int
7
sincelowestmin
sincelowestmax
int
57
sincelowestmax
length
int
20
length
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