Zeal Terminal Open in Zeal Terminal

Pine Script v5 · Indicator

DBMA - Dual Bollinger Moving Average

A Pine Script v5 indicator built on SMA or EMA or VWMA (close, 20), Stdev (close, 20) and SMA (ta.tr, 20). It draws 5 lines and 4 fills on the price chart. 17 settings; defaults include MA length 20, MA type SMA and MA source close.

Generated from the script's code by a template: every clause is a fact read from the source. Not written by a person or a model, and not taken from the author's description.

Does DBMA - Dual Bollinger Moving Average repaint?
No
No repainting patterns were found in the source, and a live tick-by-tick replay matched history on 300 of 300 bars.
How many settings does DBMA - Dual Bollinger Moving Average have?
17
Defaults include MA length 20, MA type SMA, MA source close.
Does DBMA - Dual Bollinger Moving Average run in Pine Script v6?
Yes
Every plotted value identical on BTCUSDT 1D, 1,000 bars, in Zeal Terminal's engine. Both versions were run on Zeal Terminal's engine, and the results are identical. The v6 script can be downloaded below.
Does DBMA - Dual Bollinger Moving Average draw on the price chart?
Yes
It is declared with overlay = true.
Does DBMA - Dual Bollinger Moving Average run in Zeal Terminal?
Yes
It compiles in 27 ms and runs 1,000 bars in 49 ms, in the browser.

BTCUSDT · 1D · default settings

  • Bollingerised Moving Average
  • High-compression Squeeze
  • Mid-compression Squeeze
  • Low-compression Squeeze
  • Fired Squeeze
  • No Squeeze
Prerendered with the defaults. Change anything and run it here. The script runs in your browser.
Settings (9)
40,00060,00080,000100,000120,000AprJulOct2025AprJulOct2026AprJulOct
Binance BTCUSDT 1D candles, 26 Jan 2024 to 21 Oct 2026, 1,000 bars, default settings. Lines and shading are what the script draws. Zeal Terminal's engine currently merges fill() calls that share a title, so it would draw 1 of this script's 4 fills; this page gives each call its own title to draw all of them.
High-compression Squeeze
2.1%
of bars
Mid-compression Squeeze
27.4%
of bars
Low-compression Squeeze
27.4%
of bars
Fired Squeeze
41.1%
of bars
No Squeeze
2.0%
of bars

Share of 1,000 bars spent in each state with the default settings.

Review

What a careful reader of this script would point out, found by checking the source and the backtest.

  • Likely bug

    The “WMA” option calculates VWMA line 27

    Choosing WMA in “MA type” runs ta.vwma, not ta.wma. Anyone picking WMA gets a different average from the one they asked for.

    MA_type == 'WMA' ? ta.vwma(MA_type == 'WMA' ? ta.wma(
  • Likely bug

    ta.stdev(close, 20) ignores the settings line 61

    Line 61 hard-codes close where line 32 uses “MA source” and 20 where line 32 uses “MA length”. Changing those settings moves one band but not this one.

    ta.stdev(close, 20)ta.stdev(MA_source, MA_length)
  • Note

    3 settings have no label

    In the settings dialog MA_length (line 6), MA_type (line 7), MA_source (line 8) show an empty name. The labels on this page come from the variable names.

  • Note

    No alerts

    The script declares no alertcondition, so you can't be notified when its state changes.

Settings

Every input the script declares, with its default and what it feeds. Bounds are the ones the script enforces.

SettingDefaultType and rangeFeeds
Moving Average
MA length (no label in the script)20int · min 1 · max 1000BMA devBB devKC
MA type (no label in the script)SMAstring · options ['SMA', 'EMA', 'WMA']BMA
MA source (no label in the script)closesourceBMA devBB
MA color (no label in the script)color.greencolorBollingerised Moving Average
MA line width1int · min 1 · max 4Bollingerised Moving Average
Bollinger Bands
Show Upper BandstrueboolUpper Far Band Upper Near Band
Show Lower BandsfalseboolLower Far Band Lower Near Band
Near Band0.5float · min 0 · max 3 · step 0.5devhalf
Color Orange Half (no label in the script)color.new(color.orange, 85)colorbb_colorHalf
Far Band1float · min 0 · max 3 · step 0.5devBB
Color Orange One (no label in the script)color.new(color.orange, 90)colorbb_colorOne
Squeeze
Squeeze Colorstrueboolbb_colorOne bb_colorHalf
High-compression Squeezecolor.redcolorsq_color
Mid-compression Squeezecolor.orangecolorsq_color
Low-compression Squeezecolor.yellowcolorsq_color
Fired Squeezecolor.greencolorsq_color
No Squeezecolor.bluecolorsq_color

What it calculates

  • SMA / EMA / VWMAMA source (close), MA length (20) · chosen by MA typeBMA · line 27
  • StdevMA source (close), MA length (20)devBB · line 32
  • SMAta.tr, MA length (20)devKC · line 33
  • Stdevclose, 20devhalf · line 61

Signal flow

How price data and settings reach what is drawn. Each box is a name in the script, or several computed the same way; each arrow is a value one of them reads. Hover a box for its members.

closecloseprice dataMA_typeMA typesetting · SMAMA_lengthMA lengthsetting · 20BB_stdev_farFar Bandsetting · 1high · low · closehigh · low · closeprice dataBB_stdev_nearNear Bandsetting · 0.5BMASMA / EMA / VWMA→ BMA · by MA typedevBBStdev→ devBBdevKCSMA→ devKCdevhalfStdev→ devhalfupBB, lowBB, upper, lowerupBB · lowBB +24 valuesupKCWide, lowKCWide, upKCNormal, lowKCNormal, upKCNarrow, lowKCNarrowupKCWide · lowKCWide +46 valuesupperhalf, lowerhalfupperhalf · lowerhalf2 valuessqzOnWide, sqzOnNormal, sqzOnNarrow, sqzOffWide, noSqzsqzOnWide · sqzOnNormal…5 conditionssq_color, bb_colorOne, bb_colorHalfColoursq_color · bb_colorOne +1plot:28Bollingerised Moving Av…plotplot:57Upper Far Bandplotplot:58Lower Far Bandplotfill:BB BackgroundBB Backgroundfill × 4plot:64Upper Near Bandplotplot:65Lower Near Bandplot

What it draws

OutputCallValueBy defaultLine
Bollingerised Moving AverageplotBMAShown28
Upper Far BandplotBB_show_upper ? upper : naShown “Show Upper Bands”57
Lower Far BandplotBB_show_lower ? lower : naHidden “Show Lower Bands”58
BB Backgroundfillp1Shown59
BB Backgroundfillp1Shown60
Upper Near BandplotBB_show_upper ? upperhalf : naShown “Show Upper Bands”64
Lower Near BandplotBB_show_lower ? lowerhalf : naHidden “Show Lower Bands”65
BB Backgroundfillp1Shown66
BB Backgroundfillp1Shown67

The shading takes one of 5 colours on every bar, each a state the script names in its settings: High-compression Squeeze Mid-compression Squeeze Low-compression Squeeze Fired Squeeze No Squeeze

Does it repaint?

No

No repainting patterns in the source, and the live replay matched history.

300/300bars identical at close when replayed liveThe last 300 bars, from 26 Dec 2025, were fed to the engine as live ticks, four per bar, and compared with the historical run. On 45 of them the colour changed while the bar was forming before it settled.
  • ClearHigher-timeframe dataThe script requests no other symbol or timeframe.
  • ClearFuture-bar referencesNo negative history offsets such as close[-1].
  • ClearIntrabar recalculationNo varip or realtime-only state. Values move while a bar forms and settle when it closes, as every indicator's do.

The checks read the source; the replay runs it. Together they catch the common causes, not every possible one.

Other markets

The same script with default settings on 8 Binance markets, each the most recent 1,000 bars.

MarketHigh-compression SqueezeMid-compression SqueezeLow-compression SqueezeFired SqueezeNo Squeeze
BTCUSDT 1D2% of bars3.9% vs 5.7%27% of bars4.9% vs 5.7%27% of bars5.6% vs 5.7%41% of bars5.7% vs 5.7%2% of bars—
BTCUSDT 4h4% of bars1.4% vs 1.8%22% of bars1.9% vs 1.8%32% of bars1.9% vs 1.8%40% of bars1.6% vs 1.8%2% of bars—
ETHUSDT 1D6% of bars9.2% vs 8.5%19% of bars8.6% vs 8.5%26% of bars8.5% vs 8.5%47% of bars8.0% vs 8.5%2% of bars—
ETHUSDT 4h9% of bars2.1% vs 2.4%27% of bars2.3% vs 2.4%23% of bars2.5% vs 2.4%40% of bars2.7% vs 2.4%2% of bars—
SOLUSDT 1D1% of bars12.3% vs 9.9%25% of bars10.3% vs 9.9%24% of bars8.4% vs 9.9%48% of bars9.4% vs 9.9%2% of bars—
SOLUSDT 4h3% of bars3.0% vs 2.9%26% of bars2.5% vs 2.9%30% of bars2.7% vs 2.9%40% of bars3.0% vs 2.9%2% of bars—
BNBUSDT 1D3% of bars5.6% vs 6.2%28% of bars5.1% vs 6.2%27% of bars6.3% vs 6.2%39% of bars7.7% vs 6.2%2% of bars—
BNBUSDT 4h3% of bars1.8% vs 2.0%22% of bars2.0% vs 2.0%34% of bars1.6% vs 2.0%40% of bars2.0% vs 2.0%2% of bars—

Second line: the average size of the move over the next 10 bars after the colour first appears, against the average 10-bar move on any bar.

Similar scripts

Indicators and strategies built from the same calculations.

ScriptSharesType
Bollinger Band with Fib Golden Ratio (0.618) by mohaneevwma stdev emav4 strategy
Volume Weighted Bollinger Bands Strategy by Ankit_1618ema sma stdevv4 strategy
BB21_MA200_Strategy by mohaneeema sma stdevv4 strategy
Super Breakout day trading by beststockalertstdev sma emav4 strategy
Super Auto Breakout Day Trade Volatile stocks by beststockalertstdev sma emav4 strategy

Upgrade and export

Written in Pine Script v5. The clean-v5 step types the settings and moves when = into if blocks, which v6 requires; it is run before and after like any upgrade.

  • No v6-only features. v6 is not needed to run this script.

Clean v5

Verified

Nothing to change.

Does it run in Pine Script v6?

Yes

Every plotted value identical on BTCUSDT 1D, 1,000 bars, in Zeal Terminal's engine. Both versions were run on Zeal Terminal's engine, and the results are identical. It differs from the v5 version by 1 edit.

Download the v6 script

⋯// © finallynitin-//@version=5+//@version=6indicator(title='Dual Bollinger Moving Average', shorttitle='DBMA', overlay=true)⋯

Where it runs

EngineCompilesRunsMatches TradingView
Zeal Terminal · OpenPineScript v2Yes 27 msWith a workaround 1,000 bars in 49 msNot measured
PineTSNot testedNot testedNot measured

Zeal Terminal's engine currently merges fill() calls that share a title, so it would draw 1 of this script's 4 fills; this page gives each call its own title to draw all of them.

“Matches TradingView” needs this script's own output exported from TradingView and compared bar by bar, which has not been done for this script. The engine is built on OpenPineScript, whose conformance results are in its conformance report.

Source

Copied verbatim from the author's published script, with its licence header intact. The author may have updated the original since this snapshot.

// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/// © finallynitin//@version=5indicator(title='Dual Bollinger Moving Average', shorttitle='DBMA', overlay=true)string GRP1             = "════════ Moving Average ═════════"MA_length = input.int(title='', minval=1, maxval=1000, defval=20, inline='line 1', group=GRP1)MA_type = input.string(title='', options=['SMA', 'EMA', 'WMA'], defval='SMA', inline='line 1', group=GRP1)MA_source = input.source(title='', defval=close, inline='line 1', group=GRP1)MA_color = input.color(title='', defval=color.green, inline='line 1', group=GRP1)MA_width = input.int(title='MA line width', defval=1, minval=1, maxval=4, inline='line 2', group=GRP1)string GRP2             = "════════ Bollinger Bands ═════════"BB_show_upper = input.bool(title='Show Upper Bands', defval=true, inline='line 1', group=GRP2)BB_show_lower = input.bool(title='Show Lower Bands', defval=false, inline='line 2', group=GRP2)BB_stdev_near = input.float(title='Near Band', minval=0, maxval=3, defval=0.5, step = 0.5, inline='line 3', group=GRP2)colorOrangeHalf = input.color(color.new(color.orange, 85), '', inline='line 3', group=GRP2)BB_stdev_far = input.float(title='Far Band', minval=0, maxval=3, defval=1, step = 0.5, inline='line 4', group=GRP2)colorOrangeOne = input.color(color.new(color.orange, 90), '', inline='line 4', group=GRP2)string GRP3             = "════════ Squeeze ═════════"toggleSQZColors = input.bool(title='Squeeze Colors', defval=true, inline='line 3', group=GRP3)colorRed = input.color(color.red, 'High-compression Squeeze', group=GRP3)colorOrange = input.color(color.orange, 'Mid-compression Squeeze', group=GRP3)colorYellow = input.color(color.yellow, 'Low-compression Squeeze', group=GRP3)colorGreen = input.color(color.green, 'Fired Squeeze', group=GRP3)colorBlue = input.color(color.blue, 'No Squeeze', group=GRP3)//--------BMA------BMA = 0.0BMA := MA_type == 'SMA' ? ta.sma(MA_source, MA_length) : MA_type == 'EMA' ? ta.ema(MA_source, MA_length) : MA_type == 'WMA' ? ta.vwma(MA_source, MA_length) : nap1 = plot(BMA, title='Bollingerised Moving Average', color=MA_color, linewidth=MA_width)//--------SQUEEZE------// original concept from John Carter's book "Mastering the Trade"// based on LazyBear's script (Squeeze Momentum Indicator) https://in.tradingview.com/script/nqQ1DT5a-Squeeze-Momentum-Indicator-LazyBear/devBB = BB_stdev_far * ta.stdev(MA_source, MA_length)devKC = ta.sma(ta.tr, MA_length)//Bollinger 2xupBB = BMA + devBB * 2lowBB = BMA - devBB * 2//Keltner 2xupKCWide = BMA + devKC * 2lowKCWide = BMA - devKC * 2//Keltner 1.5xupKCNormal = BMA + devKC * 1.5lowKCNormal = BMA - devKC * 1.5//Keltner 1xupKCNarrow = BMA + devKClowKCNarrow = BMA - devKCsqzOnWide = lowBB >= lowKCWide and upBB <= upKCWide  //Low-compression Squeeze: YELLOWsqzOnNormal = lowBB >= lowKCNormal and upBB <= upKCNormal  //Mid-compression Squeeze: ORANGEsqzOnNarrow = lowBB >= lowKCNarrow and upBB <= upKCNarrow  //High-compression Squeeze: REDsqzOffWide = lowBB < lowKCWide and upBB > upKCWide  //Fired Squeeze: GREENnoSqz = sqzOnWide == false and sqzOffWide == false  //No Squeeze: BLUEsq_color = noSqz ? colorBlue : sqzOnNarrow ? colorRed : sqzOnNormal ? colorOrange : sqzOnWide ? colorYellow : colorGreenbb_colorOne = toggleSQZColors ? color.new(sq_color, 80) : colorOrangeOnebb_colorHalf = toggleSQZColors ? color.new(sq_color, 80) : colorOrangeHalf//--------BOLLINGER BANDS------upper = BMA + devBBlower = BMA - devBBp2 = plot(BB_show_upper ? upper : na, 'Upper Far Band', color=color.new(color.orange, 100))p3 = plot(BB_show_lower ? lower : na, 'Lower Far Band', color=color.new(color.red, 100))fill(p1, p2, title='BB Background', color=bb_colorOne)fill(p1, p3, title='BB Background', color=bb_colorOne)devhalf = BB_stdev_near * ta.stdev(close, 20)upperhalf = BMA + devhalflowerhalf = BMA - devhalfp4 = plot(BB_show_upper ? upperhalf : na, 'Upper Near Band', color=color.new(color.orange, 100))p5 = plot(BB_show_lower ? lowerhalf : na, 'Lower Near Band', color=color.new(color.red, 100))fill(p1, p4, title='BB Background', color=bb_colorHalf)fill(p1, p5, title='BB Background', color=bb_colorHalf)