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
41 lines of Pine Script v4 from Bollinger band (band display 5σ).pine, published under GPL-3.0. Keep the author's credit and licence lines when you reuse it.
Bollinger band (band display 5σ).pine
//@version=4
strategy(title="Bollinger band (band display 5σ)", overlay=true)
//sma算出
pine_sma(x, y) =>
sum = 0.0
for i = 0 to y - 1
sum := sum + x[i] / y
sum
dev = stdev(close,20)
basis = pine_sma(close,20)
upper_1 = basis + dev
lower_1 = basis - dev
upper_2 = basis + dev * 2
lower_2 = basis - dev * 2
upper_3 = basis + dev * 3
lower_3 = basis - dev * 3
upper_4 = basis + dev * 4
lower_4 = basis - dev * 4
upper_5 = basis + dev * 5
lower_5 = basis - dev * 5
plot(basis, title='25MA線色', color=color.blue, linewidth=2,transp=100)
u1 = plot(upper_1, title='+1σ線色',transp=100)
l1 = plot(lower_1, title='-1σ線色',transp=100)
u2 = plot(upper_2, title='+2σ線色',transp=100)
l2 = plot(lower_2, title='-2σ線色',transp=100)
u3 = plot(upper_3, title='+3σ線色',transp=100, color=color.orange)
l3 = plot(lower_3, title='-3σ線色',transp=100, color=color.orange)
u4 = plot(upper_4, title='+4σ線色',transp=100, color=color.red)
l4 = plot(lower_4, title='-4σ線色',transp=100, color=color.red)
u5 = plot(upper_5, title='+5σ線色',transp=80, color=color.purple)
l5 = plot(lower_5, title='-5σ線色',transp=80,color=color.purple)
fill(u1,l1, title='±1σ帯域色',color=color.aqua, transp=80)
fill(u1,u2, title='+2σ帯域色',color=color.yellow, transp=80)
fill(l1,l2, title='-2σ帯域色',color=color.yellow, transp=80)
fill(u2,u3, title='+3σ帯域色',color=color.orange, transp=80)
fill(l2,l3, title='-3σ帯域色',color=color.orange, transp=80)
fill(u3,u4, title='+4σ帯域色',color=color.red, transp=80)
fill(l3,l4, title='-4σ帯域色',color=color.red, transp=80)
fill(u4,u5, title='+5σ帯域色',color=color.purple, transp=80)
fill(l4,l5, title='-5σ帯域色',color=color.purple, transp=80)
Expand (46 lines)
Overview
Bollinger band (band display 5σ) draws the basis and each upper and lower band on the price chart, then fills the zones between successive bands in different colors. The length and deviation multiples are fixed because no inputs are defined. The shown code contains no order entries, exits, or stop loss.
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.
Alert BB + RSI [Alorse] is a multi-symbol mean-reversion strategy designed for cryptocurrency trading. It evaluates Bollinger Bands and the Relative Strength Index (RSI) across up to 20 user-defined ticker symbols simultaneously. The strategy enters long posit
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
This strategy detects price breakouts above rolling highest highs or below lowest lows over a customizable lookback period. It includes optional volume spike and ATR volatility threshold filters, along with bar confirmation rules. Positions are taken upon conf
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