Building a Smart Money Concepts Indicator in Pine Script v6
Step-by-step guide to coding Order Blocks, CHoCH, FVG and Liquidity Zones in TradingView Pine Script v6 — with webhook alert integration.
What is Smart Money Concepts (SMC)?
SMC is a price action methodology based on how institutional traders (banks, hedge funds) move markets. Key concepts:
- Order Blocks (OB): Supply/demand zones where institutions placed large orders
- CHoCH: Change of Character — first sign of trend reversal
- FVG: Fair Value Gap — imbalance in price, usually filled later
- Liquidity: Where retail stop losses cluster (above/below swing highs/lows)
Setting Up Pine Script v6
****`pine
//@version=6
indicator("SMC Suite", overlay=true, max_lines_count=500, max_boxes_count=200)
// ─── Inputs ──────────────────────────────────────────────────────
int ob_length = input.int(5, "OB Lookback", minval=1)
bool show_fvg = input.bool(true, "Show FVG")
bool show_choch = input.bool(true, "Show CHoCH")
color bull_color = input.color(color.new(#26a69a, 80), "Bullish color")
color bear_color = input.color(color.new(#ef5350, 80), "Bearish color")
****`
Detecting Order Blocks
An Order Block is the last bearish candle before a bullish impulse (or vice versa):
****`pine
// Bullish OB = last bearish candle before up-impulse
bullish_impulse = close > high[ob_length]
bearish_candle = close[1] < open[1]
if bullish_impulse and bearish_candle
box.new(bar_index[1], high[1], bar_index + 10, low[1],
bgcolor=bull_color, border_color=color.new(#26a69a, 40))
****`
Detecting CHoCH (Change of Character)
****`pine
// Track swing highs/lows
var float last_swing_high = na
var float last_swing_low = na
pivot_high = ta.pivothigh(high, 5, 5)
pivot_low = ta.pivotlow(low, 5, 5)
if not na(pivot_high)
last_swing_high := pivot_high
if not na(pivot_low)
last_swing_low := pivot_low
// CHoCH = price breaks below last swing low in uptrend
choch_bear = close < last_swing_low and close[1] >= last_swing_low
choch_bull = close > last_swing_high and close[1] <= last_swing_high
if show_choch and choch_bear
label.new(bar_index, high, "CHoCH ↓",
style=label.style_label_down,
color=color.new(#ef5350, 0), textcolor=color.white)
****`
Fair Value Gaps (FVG)
****`pine
// Bullish FVG: gap between candle[2] high and candle[0] low
bullish_fvg = low > high[2] and show_fvg
bearish_fvg = high < low[2] and show_fvg
if bullish_fvg
box.new(bar_index[1], low, bar_index + 20, high[2],
bgcolor=color.new(#26a69a, 88),
border_color=color.new(#26a69a, 50))
****`
Adding Webhook Alerts
The real power is connecting alerts to your broker:
****pine // Alert when price enters an OB alertcondition(bullish_fvg, "Bullish FVG formed", "{{ticker}} — Bullish FVG on {{interval}}. Price: {{close}}") ****
Then in TradingView → Create Alert → set webhook URL to your execution server.
Want the Full Indicator?
The complete version with all features is available in my Marketplace — includes 12 alert types, multi-timeframe confluence and full documentation.