Indicator · Pine Script v5 · Own pane

15m BB-SMC Confluence Oscillator

by caizongxun

An oscillator pane that plots a Bollinger Band z-score as coloured columns with reference lines at plus and minus two and three.

View on GitHub

GitHub stars1on the repository
Pine versionv5runs as is
Lines of code124
Settings6inputs
LicenceMIT
Last update8 months ago21 Feb 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

124 lines of Pine Script v5 from pine scripts/15m_BB_SMC_Confluence_Oscillator.pine, published under MIT. Keep the author's credit and licence lines when you reuse it.

15m_BB_SMC_Confluence_Oscillator.pine
//@version=5
indicator("15m BB-SMC Confluence Oscillator [FTM]", shorttitle="BB-SMC Osc", overlay=false)

// ==========================================
// 1. INPUTS & CONFIGURATION
// ==========================================
grp_bb = "Bollinger Bands Settings"
bb_len = input.int(20, "Length", group=grp_bb)
bb_mult = input.float(2.0, "Multiplier", group=grp_bb)

grp_regime = "Volatility Regime"
lb_period = input.int(100, "Lookback for Percentile", group=grp_regime)
sqz_thresh = input.int(20, "Squeeze Threshold (%)", group=grp_regime)
exp_thresh = input.int(80, "Expansion Threshold (%)", group=grp_regime)

grp_smc = "SMC Structure"
pivot_len = input.int(3, "Pivot Lookback (Left/Right)", group=grp_smc)

// ==========================================
// 2. CALCULATIONS
// ==========================================

// --- Component A: Volatility Regime ---
// Standard BB Calc
basis = ta.sma(close, bb_len)
dev = ta.stdev(close, bb_len)
upper = basis + dev * bb_mult
lower = basis - dev * bb_mult

// Width & Percentile Rank
bb_width = (upper - lower) / basis

// Calculate Percentile Rank manually
count_lower = 0.0
for i = 1 to lb_period
    if bb_width[i] < bb_width
        count_lower += 1.0
width_percentile = (count_lower / lb_period) * 100

// Define Regime States
is_squeeze = width_percentile < sqz_thresh
is_expansion = width_percentile > exp_thresh

// --- Component B: Mean Reversion Pressure (Z-Score) ---
// Z-Score: How many deviations away from mean is the price?
z_score = (close - basis) / dev

// --- Component C: SMC Micro-Structure ---
// Identify Pivot Highs/Lows (Note: These lag by 'pivot_len' bars)
ph = ta.pivothigh(high, pivot_len, pivot_len)
pl = ta.pivotlow(low, pivot_len, pivot_len)

// Persist the MOST RECENT valid pivot levels to compare current price against
var float last_ph = na
var float last_pl = na

if not na(ph)
    last_ph := ph
if not na(pl)
    last_pl := pl

// --- SIGNAL LOGIC (Trigger Events) ---

// 1. Liquidity Sweeps (Turtle Soup)
// Price pierces the level but closes inside
bear_sweep = high > last_ph and close < last_ph and not na(last_ph)
bull_sweep = low < last_pl and close > last_pl and not na(last_pl)

// 2. Valid BOS (Displacement)
// Price pierces and closes outside
bull_bos = close > last_ph and not na(last_ph)
bear_bos = close < last_pl and not na(last_pl)

// ==========================================
// 3. PLOTTING & VISUALIZATION
// ==========================================

// A. Z-Score Histogram (The Base)
// Color logic: Grey if Squeeze (Noise), Bright if Expansion (Action), Dark if Normal
z_color = is_squeeze ? color.new(color.gray, 50) : 
          is_expansion ? (z_score > 0 ? color.new(color.teal, 30) : color.new(color.red, 30)) : 
          color.new(color.blue, 50)

plot(z_score, "Z-Score Pressure", color=z_color, style=plot.style_columns, linewidth=2)

// B. Overbought/Oversold Zones
h_line_top = hline(2.0, "Overbought (+2)", color=color.gray, linestyle=hline.style_dotted)
h_line_bot = hline(-2.0, "Oversold (-2)", color=color.gray, linestyle=hline.style_dotted)
hline(0, "Mean", color=color.white, linestyle=hline.style_solid)

// Fill background for extreme zones
fill(h_line_top, hline(3.0), color=color.new(color.red, 90), title="Extreme OB Zone")
fill(h_line_bot, hline(-3.0), color=color.new(color.green, 90), title="Extreme OS Zone")

// C. Signal Markers (Confluence Events)

// Bullish Reversal Confluence: 
// 1. Oversold (Z < -1.5) 
// 2. Bullish Sweep (Stop Run)
bull_signal = bull_sweep and z_score < -1.5
plotshape(bull_signal, title="Bull Sweep Reversal", style=shape.triangleup, location=location.bottom, color=color.green, size=size.small, offset=0)

// Bearish Reversal Confluence:
// 1. Overbought (Z > 1.5)
// 2. Bearish Sweep (Stop Run)
bear_signal = bear_sweep and z_score > 1.5
plotshape(bear_signal, title="Bear Sweep Reversal", style=shape.triangledown, location=location.top, color=color.red, size=size.small, offset=0)

// Trend Continuation (Breakout)
// 1. Not Overextended yet (Z between -2 and 2)
// 2. Valid BOS
// 3. Not in deep squeeze (width > 20)
bull_cont = bull_bos and z_score < 2.0 and z_score > 0 and not is_squeeze
bear_cont = bear_bos and z_score > -2.0 and z_score < 0 and not is_squeeze

// Only plot continuation if it's a fresh break (simple filter)
plotshape(bull_cont and not bull_cont[1], title="Bull BOS", style=shape.circle, location=location.absolute, color=color.lime, size=size.tiny, offset=0, text="BOS", textcolor=color.lime)
plotshape(bear_cont and not bear_cont[1], title="Bear BOS", style=shape.circle, location=location.absolute, color=color.orange, size=size.tiny, offset=0, text="BOS", textcolor=color.orange)

// ==========================================
// 4. ALERTS
// ==========================================
alertcondition(bull_signal, title="Bullish Reversal Sweep", message="FTM 15m: Bullish Sweep + Oversold Detected")
alertcondition(bear_signal, title="Bearish Reversal Sweep", message="FTM 15m: Bearish Sweep + Overbought Detected")

Overview

Colour depends on a volatility regime taken from the percentile rank of band width, separating squeeze, normal and expansion. It also tracks confirmed pivot highs and lows to flag liquidity sweeps and break-of-structure events. Inputs set band length, multiplier, percentile lookback, regime thresholds and pivot length. Pivots are confirmed with a delay.

Details

Published by

caizongxun on GitHub

Type

Indicator, Pine Script v5

Draws

Separate pane below the chart

Category

SMC / ICT / price action, Volatility & bands, Mean reversion

Markets

Crypto

Timeframes

M15-H1

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
Lengthint20bb_len
Multiplierfloat2.0bb_mult
Lookback for Percentileint100lb_period
Squeeze Threshold (%)int20sqz_thresh
Expansion Threshold (%)int80exp_thresh
Pivot Lookback (Left/Right)int3pivot_len
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

TylerG FVG BB Reversal

by TradersPost
218 stars

This indicator identifies mean-reversion setups by combining Bollinger Bands with Fair Value Gaps (FVGs). It tracks FVGs that print outside the upper or lower Bollinger Bands and counts them toward an alert threshold. Signals trigger upon gap mitigation (by to

Indicator v6 SMC / ICT / price actionVolatility & bands
Updated 3 months ago · None stated GitHub repository of TylerG FVG BB Reversal
55 stars

This Pine Script indicator overlays institutional liquidity levels on the price chart. It identifies order block levels using pivot highs and lows, then draws mean reversion lines from the 20 and 50 period simple moving averages, a volatility range midpoint pr

Indicator v6 Support & resistanceSMC / ICT / price action Repaints
Updated 6 months ago · Apache-2.0 GitHub repository of AAPL Institutional Liquidity Grid
261 stars

This indicator calculates standardized z-scores of price data across four different lookback periods (6, 14, 26, and 100). Standardizing data subtracts the moving average from the price and divides by the standard deviation. It applies a Double Exponential Mov

Indicator v5 Mean reversionVolatility & bands
114 stars

This indicator implements a dual-direction variation of the Williams Vix Fix oscillator in a separate pane. It normalizes price data using min-max scaling to compute both upward and downward synthetic volatility metrics across two selectable calculation modes

Indicator v4 Volatility & bandsMean reversion
Updated 1 year ago · None stated GitHub repository of Combo Williams Vix Fix (Twin)
99 stars

The Mean Squared Error indicator calculates the mean of squared differences between a source series and its EMA, averaged via a rolling buffer acting as SMA. This error metric plots as a filled red area on a separate pane, while the EMA overlays as a yellow li

Indicator v6 Volatility & bandsMean reversion
Updated 4 weeks ago · Apache-2.0 GitHub repository of Mean Squared Error (MSE)

This indicator classifies market behavior into momentum, mean-reversion, noise, or mixed regimes. It fuses four statistical predictability sensors—Variance Ratio across multiple horizons, return autocorrelation, Hurst exponent approximation, and fractal effici

Indicator v6 TrendMean reversion
Updated 2 days ago · MIT GitHub repository of Predictability Regime Index [WavesUnchained]

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