Indicator · Pine Script v6 · On the chart

PipAtlas Bollinger Bands

by pipatlas26

PipAtlas Bollinger Bands calculates standard Bollinger Bands using a simple moving average basis and population standard deviation bands.

View on GitHub

GitHub stars1on the repository
Pine versionv6current
Lines of code40
Settings4inputs
LicenceMIT
Last update12 days ago12 Nov 2026

Add It to Your TradingView Chart

  1. 1Copy the scriptPress Copy script above, or the copy button on the code below.
  2. 2Open the Pine EditorOpen a TradingView chart and choose Pine Editor at the bottom of the screen.
  3. 3Paste over the templateCreate a new indicator, select all of the template text and paste. Press Save and give it a name.
  4. 4Add it to the chartPress Add to chart, then adjust the settings with the gear icon next to its name.

Source Code

40 lines of Pine Script v6 from tradingview/pipatlas-bollinger-bands.pine, published under MIT. Keep the author's credit and licence lines when you reuse it.

pipatlas-bollinger-bands.pine
//@version=6
// PipAtlas Bollinger Bands — a 20-period moving average with bands two standard
// deviations away, plus an honest note about what a band tag does not mean.
// Education only, never financial advice.
// https://pipatlas.com
indicator("PipAtlas Bollinger Bands", shorttitle = "PA BB", overlay = true)

len   = input.int(20,    "Period",        minval = 2,   maxval = 500)
mult  = input.float(2.0, "Deviations",    minval = 0.5, maxval = 5.0, step = 0.1)
src   = input.source(close, "Source")
showFill = input.bool(true, "Shade the band")

// Basis is the SMA of the source; the bands sit mult deviations away. TradingView's
// ta.stdev is the population form, which is what the MT4/MT5 builds of this
// indicator use too, so all three platforms line up bar for bar.
basis = ta.sma(src, len)
dev   = mult * ta.stdev(src, len)
upper = basis + dev
lower = basis - dev

pU = plot(upper, "Upper band", color = color.new(color.red, 20), linewidth = 1)
pL = plot(lower, "Lower band", color = color.new(color.red, 20), linewidth = 1)
plot(basis, "Basis", color = color.new(color.blue, 0), linewidth = 2, style = plot.style_line)
fill(pU, pL, color = showFill ? color.new(color.blue, 93) : na, title = "Band fill")

// A close outside a band is a statement about how far price travelled relative to
// its own recent noise. It is not a reversal signal: in a trend, price rides the
// upper or lower band for weeks at a time.
tagUp = ta.crossover(close, upper)
tagDn = ta.crossunder(close, lower)
plotshape(tagUp, title = "Closed above the upper band", style = shape.triangledown, location = location.abovebar, color = color.new(color.maroon, 0), size = size.tiny)
plotshape(tagDn, title = "Closed below the lower band", style = shape.triangleup,   location = location.belowbar, color = color.new(color.teal, 0),   size = size.tiny)

// Band width, in percent of the basis, is the volatility read most traders are
// actually looking for when they stare at the bands.
bw = basis != 0 ? (upper - lower) / basis * 100.0 : na
plot(bw, "Band width %", display = display.data_window)

alertcondition(tagUp, "Close above upper band", "PipAtlas Bollinger: price closed above the upper band")
alertcondition(tagDn, "Close below lower band", "PipAtlas Bollinger: price closed below the lower band")

Overview

PipAtlas Bollinger Bands plots the upper band, lower band, and basis line on the main price chart with optional background shading between the outer bands. Small triangle shapes signal when price closes above the upper band or below the lower band. Inputs allow adjusting the period length, standard deviation multiplier, price source, and background shading toggle.

Details

Published by

pipatlas26 on GitHub

Draws

On the price chart

Markets

Any symbol

Timeframes

Any timeframe

Risk Notes

No repainting, lookahead or stacked entries were found in its code or README. That says nothing about how well it works: test it first.

Topics

expert-advisorforexmetatrader5mql4mql5pinescriptposition-sizingrisk-managementtrading-indicatorstradingview

Settings

The inputs you can change from the gear icon on the chart. Defaults are the author's.

SettingTypeDefaultVariable
Periodint20len
Deviationsfloat2.0mult
Sourcesourceclosesrc
Shade the bandbooltrueshowFill
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.

Similar Pine Scripts

321 stars

This indicator plots four customizable moving averages directly on the main price chart using default lengths of 3, 8, 21, and 50 periods. It fills the space between adjacent averages in green or maroon depending on trend alignment. Additionally, it computes B

Indicator v5 Moving averagesTrend
Updated 8 days ago · MIT GitHub repository of Multiple Moving Averages

NVDA Trend Ribbon

by longsurf-ai
280 stars

This indicator plots three exponential moving averages and ATR volatility envelopes on the price chart. It compares the fast and slow EMAs to shade a trend ribbon and marks confirmed upward and downward crossovers with triangle labels. Settings change the thre

Indicator v6 TrendMoving averages
Updated 4 weeks ago · MIT GitHub repository of NVDA Trend Ribbon

Bollinger Bands Force

by harryguiacorn
220 stars

This indicator modifies standard Bollinger Bands to measure directional trend force based on line alignment. It calculates a simple moving average basis along with upper and lower volatility bands. When all three lines move upward or downward simultaneously, i

Indicator v5 Volatility & bandsTrend
Updated 1 year ago · None stated GitHub repository of Bollinger Bands Force

Adaptive MA Slope

by capissimo
114 stars

This indicator calculates Kaufman's Adaptive Moving Average (KAMA) on a chosen price source and determines trend direction based on the slope across a configurable lookback window. Signals can be filtered by short-term volatility expansion using ATR comparison

Indicator v4 Moving averagesTrend
Updated 2 years ago · None stated GitHub repository of Adaptive MA Slope

More Volatility & bands scripts

Related on ForexR

Trade Your Charts With a Regulated Broker

Compare brokers that connect to TradingView, with spreads, minimum deposits and leverage side by side.

Compare brokers