Indicator · Pine Script v6 · On the chart

Buddha Bollinger Bands

by DarthBuddha

A chart-overlay indicator that draws Bollinger-style envelopes from a daily, weekly or monthly anchor timeframe, so the bands stay fixed relative to a higher timeframe while viewing a lower one.

View on GitHub

GitHub stars1on the repository
Pine versionv6current
Lines of code200
Settings11inputs
LicenceMIT
Last update3 months ago15 Jul 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

200 lines of Pine Script v6 from src/BuddhaBollingerBands.pine, published under MIT. Keep the author's credit and licence lines when you reuse it.

BuddhaBollingerBands.pine
// This Pine Script™ code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © Darth_Buddha

//@version=6
indicator(
  title = 'Buddha Bollinger Bands',
  shorttitle = 'BB',
  overlay = true)

//----------------------------------------------------------------------------------------------------< CONSTANTS >---//

const color CLR_BOLLINGER = color.rgb(255, 255, 255, 50)

//-------------------------------------------------------------------------------------------------------< INPUTS >---//

const string GP_MAIN = 'Bollinger Band'
const string GP_STYLE = 'Style'

//@variable     Input : Bollinger Bands, On/Off Switch
bollinger_OnOff = input.bool(defval = true, title = 'Bollinger Bands',
  inline = '1', group = GP_MAIN)

//@variable     Input : Bollinger Bands, MA Type to use
band_MaType = input.string(defval = 'SMA', title = 'MA Type',
  options = ['SMA', 'EMA', 'RMA', 'WMA', 'VWMA'],
  inline = '1', group = GP_MAIN)

//@variable     Input : Bollinger Bands, Timeframe Anchor
bollinger_Timeframe = input.timeframe(defval = '1W', title = 'Timeframe',
  options = ['1D', '1W', '1M'],
  inline = '2', group = GP_MAIN)

//@variable     Input : Bollinger Bands, Length
bollinger_Length = input.int(defval = 21, title = 'Length',
  minval = 1, maxval = 365, step = 1,
  inline = '2', group = GP_MAIN)

//@variable     Input : Bollinger Bands, StdDev Slow
bollinger_MultSlow = input.float(defval = 2.0, title = 'StdDev Slow',
  minval = 0.25, maxval = 10.0, step = 0.25,
  inline = '3', group = GP_MAIN)

//@variable     Input : Bollinger Bands, StdDev Fast
bollinger_MultFast = input.float(defval = 3.0, title = 'StdDev Fast',
  minval = 0.25, maxval = 10.0, step = 0.25,
  inline = '3', group = GP_MAIN)

//@variable     Input : Bollinger Bands, Color
bollinger_Color = input.color(defval = CLR_BOLLINGER, title = 'Band Color',
  inline = '4', group = GP_MAIN)

//@variable     Input : Bollinger Bands, Line Width
bollinger_Lw = input.int(defval = 1, title = 'Line Size',
  options = [1, 2, 3, 4, 5],
  inline = '4', group = GP_MAIN)

//@variable     Input : Bollinger Bands, Offset
bollinger_Offset = input.int(defval = 0, title = 'Offset',
  minval = -365, maxval = 365, step = 1,
  inline = '5', group = GP_MAIN)

//@variable     Input : Bollinger Bands, Fill Transparency
band_Transparency = input.int(defval = 90, title = 'Band Fill Transparency',
  minval = 0, maxval = 100, step = 1,
  inline = '5', group = GP_STYLE)

//@variable     Input : Bollinger Bands, Extend Right
bollinger_Extend = input.bool(defval = true, title = 'Extend Right (Dotted)',
  inline = '6', group = GP_STYLE)

//----------------------------------------------------------------------------------------------------< FUNCTIONS >---//

//@function     Switch for moving averages.
//@returns      Correct moving average.
method maSwitch(simple string option, series float source, simple int length) =>
    movingAverage = switch option
        'EMA' => ta.ema(source, length)
        'SMA' => ta.sma(source, length)
        'RMA' => ta.rma(source, length)
        'VWMA' => ta.vwma(source, length)
        'WMA' => ta.wma(source, length)
    movingAverage


//@function     Time multiplyer based on current time period for Chart Point 1
//@returns      Adjusted Time based on current timeframe
method timemult(int mult) =>
    timeframe.multiplier * (timeframe.isseconds
      ? 1000 : timeframe.isminutes
      ? 60000 : timeframe.isdaily
      ? 86400000 : timeframe.isweekly
      ? 604800000 : timeframe.ismonthly
      ? 2629800000 : 1) * mult

//-------------------------------------------------------------------------------------------------< CALCULATIONS >---//

//@variable     Calculation : Bollinger Bands, Upper Slow Dev Data
bollinger_UpperSlow = request.security(syminfo.tickerid, bollinger_Timeframe,
  maSwitch(option = band_MaType, source = close, length = bollinger_Length) + (bollinger_MultSlow * ta.stdev(close, bollinger_Length)))
//@variable     Calculation : Bollinger Bands, Lower Slow Dev Data
bollinger_LowerSlow = request.security(syminfo.tickerid, bollinger_Timeframe,
  maSwitch(option = band_MaType, source = close, length = bollinger_Length) - (bollinger_MultSlow * ta.stdev(close, bollinger_Length)))
//@variable     Calculation : Bollinger Bands, Upper Fast Dev Data
bollinger_UpperFast = request.security(syminfo.tickerid, bollinger_Timeframe,
  maSwitch(option = band_MaType, source = close, length = bollinger_Length) + (bollinger_MultFast * ta.stdev(close, bollinger_Length)))
//@variable     Calculation : Bollinger Bands, Lower Fast Dev Data
bollinger_LowerFast = request.security(syminfo.tickerid, bollinger_Timeframe,
  maSwitch(option = band_MaType, source = close, length = bollinger_Length) - (bollinger_MultFast * ta.stdev(close, bollinger_Length)))

visibleBands = bollinger_OnOff and not timeframe.ismonthly

//------------------------------------------------------------------------------------------------------< VISUALS >---//

//@variable     Visual : Bollinger Bands, Slow Band Upper Plot Line
bollinger_UpperSlowPlot = plot(series = visibleBands ? bollinger_UpperSlow : na, title = 'BB',
  color = bollinger_Color, linewidth = math.max(1, bollinger_Lw), style = plot.style_line,
  offset = bollinger_Offset, editable = false, force_overlay = true)
//@variable     Visual : Bollinger Bands, Slow Band Lower Plot Line
bollinger_LowerSlowPlot = plot(series = visibleBands ? bollinger_LowerSlow : na, title = 'BB',
  color = bollinger_Color, linewidth = math.max(1, bollinger_Lw), style = plot.style_line,
  offset = bollinger_Offset, editable = false, force_overlay = true)
//@variable     Visual : Bollinger Bands, Fast Band Upper Plot Line
bollinger_UpperFastPlot = plot(series = visibleBands ? bollinger_UpperFast : na, title = 'BB',
  color = bollinger_Color, linewidth = math.max(1, bollinger_Lw), style = plot.style_line,
  offset = bollinger_Offset, editable = false, force_overlay = true)
//@variable     Visual : Bollinger Bands, Fast Band Lower Plot Line
bollinger_LowerFastPlot = plot(series = visibleBands ? bollinger_LowerFast : na, title = 'BB',
  color = bollinger_Color, linewidth = math.max(1, bollinger_Lw), style = plot.style_line,
  offset = bollinger_Offset, editable = false, force_overlay = true)
//---< Fill Upper Band Plots
fill(plot1 = bollinger_UpperSlowPlot, plot2 = bollinger_UpperFastPlot, color = color.new(color.red, band_Transparency))
//---< Fill Lower Band Plots
fill(plot1 = bollinger_LowerSlowPlot, plot2 = bollinger_LowerFastPlot, color = color.new(color.green, band_Transparency))
//@variable     Visual : Bollinger Bands, Slow Band Upper Draw Line
var line bollinger_UpperSlowLine = na
//@variable     Visual : Bollinger Bands, Fast Band Upper Draw Line
var line bollinger_UpperFastLine = na
//@variable     Visual : Bollinger Bands, Slow Band Lower Draw Line
var line bollinger_LowerSlowLine = na
//@variable     Visual : Bollinger Bands, Fast Band Lower Draw Line
var line bollinger_LowerFastLine = na

if barstate.islast and visibleBands and bollinger_Extend
    x1 = last_bar_time
    x2 = last_bar_time + timemult(1)

    if na(bollinger_UpperSlowLine)
        bollinger_UpperSlowLine := line.new(x1, bollinger_UpperSlow, x2, bollinger_UpperSlow,
          xloc = xloc.bar_time, extend = extend.right, color = bollinger_Color,
          style = line.style_dotted, width = bollinger_Lw, force_overlay = true)
    else
        line.set_xy1(bollinger_UpperSlowLine, x1, bollinger_UpperSlow)
        line.set_xy2(bollinger_UpperSlowLine, x2, bollinger_UpperSlow)
        line.set_color(bollinger_UpperSlowLine, bollinger_Color)
        line.set_width(bollinger_UpperSlowLine, bollinger_Lw)

    if na(bollinger_UpperFastLine)
        bollinger_UpperFastLine := line.new(x1, bollinger_UpperFast, x2, bollinger_UpperFast,
          xloc = xloc.bar_time, extend = extend.right, color = bollinger_Color,
          style = line.style_dotted, width = bollinger_Lw, force_overlay = true)
    else
        line.set_xy1(bollinger_UpperFastLine, x1, bollinger_UpperFast)
        line.set_xy2(bollinger_UpperFastLine, x2, bollinger_UpperFast)
        line.set_color(bollinger_UpperFastLine, bollinger_Color)
        line.set_width(bollinger_UpperFastLine, bollinger_Lw)

    if na(bollinger_LowerSlowLine)
        bollinger_LowerSlowLine := line.new(x1, bollinger_LowerSlow, x2, bollinger_LowerSlow,
          xloc = xloc.bar_time, extend = extend.right, color = bollinger_Color,
          style = line.style_dotted, width = bollinger_Lw, force_overlay = true)
    else
        line.set_xy1(bollinger_LowerSlowLine, x1, bollinger_LowerSlow)
        line.set_xy2(bollinger_LowerSlowLine, x2, bollinger_LowerSlow)
        line.set_color(bollinger_LowerSlowLine, bollinger_Color)
        line.set_width(bollinger_LowerSlowLine, bollinger_Lw)

    if na(bollinger_LowerFastLine)
        bollinger_LowerFastLine := line.new(x1, bollinger_LowerFast, x2, bollinger_LowerFast,
          xloc = xloc.bar_time, extend = extend.right, color = bollinger_Color,
          style = line.style_dotted, width = bollinger_Lw, force_overlay = true)
    else
        line.set_xy1(bollinger_LowerFastLine, x1, bollinger_LowerFast)
        line.set_xy2(bollinger_LowerFastLine, x2, bollinger_LowerFast)
        line.set_color(bollinger_LowerFastLine, bollinger_Color)
        line.set_width(bollinger_LowerFastLine, bollinger_Lw)
else
    if not na(bollinger_UpperSlowLine)
        line.delete(bollinger_UpperSlowLine)
        bollinger_UpperSlowLine := na
    if not na(bollinger_UpperFastLine)
        line.delete(bollinger_UpperFastLine)
        bollinger_UpperFastLine := na
    if not na(bollinger_LowerSlowLine)
        line.delete(bollinger_LowerSlowLine)
        bollinger_LowerSlowLine := na
    if not na(bollinger_LowerFastLine)
        line.delete(bollinger_LowerFastLine)
        bollinger_LowerFastLine := na

//----------------------------------------------------< END-CODE >----------------------------------------------------//

Overview

Buddha Bollinger Bands plots two standard deviation zones, a slower one at 2.0 and a faster one at 3.0 by default, around a selectable moving average. Settings cover the average type, length, offset, colour, line size, fill transparency and a dotted extension to the right. It produces no buy or sell signals.

Details

Published by

DarthBuddha on GitHub

Type

Indicator, Pine Script v6

Draws

On the price chart

Category

Volatility & bands

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.

Settings

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

SettingTypeDefaultVariable
Bollinger Bandsbooltruebollinger_OnOff
MA TypestringSMAband_MaType
Timeframetimeframe1Wbollinger_Timeframe
Lengthint21bollinger_Length
StdDev Slowfloat2.0bollinger_MultSlow
StdDev Fastfloat3.0bollinger_MultFast
Band ColorcolorCLR_BOLLINGERbollinger_Color
Line Sizeint1bollinger_Lw
Offsetint0bollinger_Offset
Band Fill Transparencyint90band_Transparency
Extend Right (Dotted)booltruebollinger_Extend
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

Chandelier Exit

by everget
948 stars

This indicator plots an ATR-based Chandelier Exit trailing stop on the price chart. It tracks a long stop under recent highs and a short stop above recent lows, then switches direction when price crosses the opposite stop. Buy and sell labels mark those flips.

Indicator v6 Volatility & bandsTrend Repaints
Updated 11 days ago · GPL-3.0 GitHub repository of Chandelier Exit

ICT Liquidity Void Fill

by ArunKBhaskar
575 stars

This overlay indicator marks ICT liquidity void fills on the price chart and can show long and short signals. It places a Fibonacci level inside a displacement candle, defaulting to the midpoint, and draws lines in a chosen style. Optional filters limit the fi

Indicator v6 SMC / ICT / price actionSupport & resistance
Updated 1 year ago · MPL-2.0 GitHub repository of ICT Liquidity Void Fill

This indicator plots trade entry and exit signals on the price chart by combining Bollinger Bands with optional filter conditions. It calculates standard Bollinger Bands along with RSI, Aroon, and moving average filters. Reversal signals trigger when price bre

Indicator v4 Volatility & bandsOscillators & momentum
Updated 2 months ago · None stated GitHub repository of Bollinger Bands Winner IND [Alorse]
318 stars

This indicator calculates an ATR trailing stop line derived from the highest high minus an average true range multiple over a specified lookback period. It plots the trailing stop line directly on the price chart and colors price bars based on whether the clos

Indicator v5 TrendVolatility & bands
Updated 2 months ago · MIT GitHub repository of ATR Trailing Stoploss

NVDA Trend Ribbon

by longsurf-ai
277 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 2 days ago · MIT GitHub repository of NVDA Trend Ribbon

Algo AVT

by ricardosantos79
261 stars

This indicator calculates an outlier-filtered moving average based on statistical filtering concepts. It stores close prices in a rolling array over a user-defined length, calculates the mean and standard deviation, and excludes values falling within a specifi

Indicator v4 Moving averagesVolatility & bands
Updated 4 years ago · None stated GitHub repository of Algo AVT

More indicators

Trade Your Charts With a Regulated Broker

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

Compare brokers