Open-Source Pine Script v5 Guide

Smart Money Concepts (SMC)

Institutional execution rules, audit-clean Pine Script v5 source code, and automated multi-ticker scanning.

What Is Smart Money Concepts (SMC)?

Smart Money Concepts is a price-action framework that reads charts as the footprint of institutional order flow. Its core vocabulary: Break of Structure (BOS) - price takes out a swing high/low in the direction of the trend, confirming continuation; Change of Character (CHoCH) - the first structure break against the trend, an early reversal warning; Order Blocks - the last opposing candle before an impulsive move (see our Order Block guide at /apps/tradingview-indicators/order-blocks/); Fair Value Gaps - 3-candle imbalances that price returns to fill (see /apps/tradingview-indicators/fair-value-gaps/); and Liquidity - pools of stop orders above equal highs and below equal lows that "smart money" sweeps before reversing. LuxAlgo's free Smart Money Concepts script implements all of these and is the most-liked indicator on all of TradingView.

Execution Rules & Setup Playbook

Institutional Playbook: Use structure as your bias filter: a string of bullish BOS prints means you only look for longs. A CHoCH is your warning shot - do not reverse immediately, but start watching for a retrace into the order block or fair value gap that produced the CHoCH. The classic SMC sequence is: liquidity sweep (price wicks below equal lows), CHoCH to the upside, then a pullback into the FVG/order block left by that CHoCH leg - that pullback is the entry. Trade the framework on 1-hour and 4-hour structure and execute on 5-15 minute charts; on very low timeframes every tick looks like a "break of structure."

Pine Script v5 Source Code

TradingView Pine Editor → Paste → Add to Chart
PINE SCRIPT V5 · UNLOCKED SOURCE
//@version=5
indicator("SMC Structure: BOS / CHoCH", overlay=true)

// Inputs
pivotLen = input.int(5, "Pivot Length")

// Swing structure
ph = ta.pivothigh(high, pivotLen, pivotLen)
pl = ta.pivotlow(low, pivotLen, pivotLen)

var float lastHigh = na
var float lastLow = na
var int trend = 0  // 1 = bullish structure, -1 = bearish structure

if not na(ph)
    lastHigh := ph
if not na(pl)
    lastLow := pl

// Structure breaks
breakUp = not na(lastHigh) and ta.crossover(close, lastHigh)
breakDown = not na(lastLow) and ta.crossunder(close, lastLow)

// CHoCH = first break AGAINST the prevailing trend; BOS = break WITH it
chochUp = breakUp and trend == -1
chochDown = breakDown and trend == 1
bosUp = breakUp and trend != -1
bosDown = breakDown and trend != 1

if breakUp
    trend := 1
if breakDown
    trend := -1

// Labels
plotshape(bosUp, "BOS Up", shape.labelup, location.belowbar, color.new(color.green, 0), text="BOS", textcolor=color.white, size=size.tiny)
plotshape(bosDown, "BOS Down", shape.labeldown, location.abovebar, color.new(color.red, 0), text="BOS", textcolor=color.white, size=size.tiny)
plotshape(chochUp, "CHoCH Up", shape.labelup, location.belowbar, color.new(color.teal, 0), text="CHoCH", textcolor=color.white, size=size.small)
plotshape(chochDown, "CHoCH Down", shape.labeldown, location.abovebar, color.new(color.orange, 0), text="CHoCH", textcolor=color.white, size=size.small)

Related Pine Script v5 Guides

Scan Without Coding

Skip single-chart limits — Tradestie monitors this setup across 5,000+ US stocks automatically.

Server-Side Advantage SMC infers what institutions did from candle shapes. Our Smart Money Flow dashboard measures it directly - daily open-interest changes, unusual options positioning, and accumulation signals across the whole market.
  • Real-time multi-ticker signal scanning
  • Institutional options & GEX confirmation
  • Automated email alerts on triggers
Launch Live Scanner
Check Any Stock Right Now