Indicator · Pine Script v6 · On the chart

Engulfing Off BB

by lunarticktrading· code credited to gambcl

This indicator plots Bollinger Bands on the price chart and highlights engulfing candles that touch a band.

View on GitHub

GitHub stars7on the repository
Pine versionv6current
Lines of code41
Settings5inputs
LicenceNone statedfile: MPL-2.0
Last update2 weeks ago10 Oct 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

41 lines of Pine Script v6 from Engulfing Off BB.txt, published under MPL-2.0 (file header). Keep the author's credit and licence lines when you reuse it.

Engulfing Off BB.txt
// This Pine Script® code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © gambcl

//@version=6
indicator("Engulfing Off BB", overlay = true)


////////////////////////////////////////////////////////////////////////////////
// Inputs
////////////////////////////////////////////////////////////////////////////////

i_bb_series = input.source(close, "Source", group = "Bollinger Bands")
i_bb_length = input.int(20, "Length", minval = 1, maxval = 999, group = "Bollinger Bands")
i_bb_mult = input.float(2.0, "Multiplier", minval = 0, step = 0.1, group = "Bollinger Bands")

i_bullish_color = input.color(#00c3ff, "Bullish", group = "Engulfing Candles")
i_bearish_color = input.color(#df1878, "Bearish", group = "Engulfing Candles")


////////////////////////////////////////////////////////////////////////////////
// Calculations
////////////////////////////////////////////////////////////////////////////////

[bb_middle, bb_upper, bb_lower] = ta.bb(i_bb_series, i_bb_length, i_bb_mult)

is_touching_upper_bb = (high >= bb_upper) and (low <= bb_upper)
is_touching_lower_bb = (high >= bb_lower) and (low <= bb_lower)

is_bullish_engulfing = (close >= open) and (close[1] <= open[1]) and ((close - open) > (open[1] - close[1]))
is_bearish_engulfing = (close <= open) and (close[1] >= open[1]) and ((open - close) > (close[1] - open[1]))


////////////////////////////////////////////////////////////////////////////////
// Plotting
////////////////////////////////////////////////////////////////////////////////

plot(bb_upper, "BB Upper", #512da8, 1, plot.style_line, linestyle = plot.linestyle_dotted)
plot(bb_middle, "BB Middle", color.olive, 1, plot.style_line, linestyle = plot.linestyle_dashed, display = display.none)
plot(bb_lower, "BB Lower", #512da8, 1, plot.style_line, linestyle = plot.linestyle_dotted)

barcolor(is_touching_lower_bb and is_bullish_engulfing ? i_bullish_color : (is_touching_upper_bb and is_bearish_engulfing ? i_bearish_color : na))

Overview

A bullish engulfing bar that reaches the lower band is colored with the bullish color, and a bearish engulfing bar that reaches the upper band is colored with the bearish color. The source, length, and multiplier change the band calculation. The middle band is calculated but hidden by default. It is an indicator only and does not place orders or set exits.

Details

Published by

lunarticktrading on GitHub

Code credit

gambcl, as written in the script's header

Type

Indicator, Pine Script v6

Draws

On the price chart

Category

Volatility & bands, Candlestick patterns

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
Sourcesourceclosei_bb_series
Lengthint20i_bb_length
Multiplierfloat2.0i_bb_mult
Bullishcolor#00c3ffi_bullish_color
Bearishcolor#df1878i_bearish_color
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

Body Mass Indicator

by harryguiacorn
219 stars

The Body Mass Indicator highlights candles with exceptionally large body ranges relative to recent price movement. It calculates the absolute distance between open and close prices. When enabled, it identifies bars where the body range achieves a new high over

Indicator v5 Volatility & bandsCandlestick patterns
Updated 1 year ago · None stated GitHub repository of Body Mass Indicator

Raschke Patterns

by TradersPost
218 stars

This overlay indicator marks Linda Raschke short-term bar setups on the price chart. It flags Turtle Soup and Turtle Soup plus one false breakouts of a prior extreme, 80-20 bars, inside bars, failed inside-bar breakouts, outside up and down bars, NR4 and NR7 c

Indicator v6 Candlestick patternsBreakout Repaints
Updated 3 months ago · None stated GitHub repository of Raschke Patterns

Five-in-one Strategy

by capissimo
114 stars

Five-in-one Strategy combines five analytical tools into a single price chart overlay: the Dual Thrust Trading Algorithm (DTTA), Semafore, HalfTrend, Nick Rypock Trailing Reverse, and Tweezer or Kangaroo Tail candlestick patterns. It generates trade signals us

Indicator v4 TrendBreakout Repaints
Updated 1 year ago · None stated GitHub repository of Five-in-one Strategy

Force Bar

by milocaetano
48 stars

Force Bar highlights candlesticks directly on the price chart using three distinct body and range criteria: widest range (Biggest), extreme body relative to historical average (Exhaustion), and moderate body relative to historical average (Force). Colors apply

Indicator v5 Candlestick patternsVolatility & bands
Updated yesterday · MIT GitHub repository of Force Bar

Zen Z Bars V1

by Zen-Tim
29 stars

Zen Z Bars V1 analyzes bar-by-bar price action, candle range expansion, and internal bar strength (IBS). It identifies breakouts, inside and outside bars, climax candles based on range expansion factors, and tiered range multiple bars. The indicator draws brea

Indicator v5 Candlestick patternsBreakout
Updated 2 weeks ago · MIT GitHub repository of Zen Z Bars V1
15 stars

This indicator plots Bollinger Bands and smoothed HAMA candles on the price chart. It builds each candle from separate moving averages of open, high, low and close, using selectable EMA, SMA or WMA lengths. A simple moving average forms the band basis, and an

Indicator v5 Candlestick patternsMoving averages
Updated 4 months ago · Apache-2.0 GitHub repository of NSDT HAMA Candles with Bollinger Bands

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