Quantitative Smart Money Concepts Framework# Quantitative SMC Framework
An implementation of Smart Money Concepts that combines market structure (BOS / CHoCH / MSS), order blocks, fair value gaps, liquidity sweeps, equal highs/lows, and premium/discount zones into a single confluence framework. The methodology itself is public trading theory from Inner Circle Trader (ICT). The algorithms used to detect each component, and the scoring system that ties them together, are original work.
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
WHY THESE COMPONENTS BELONG IN ONE SCRIPT
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
SMC trading depends on confluence. A standalone order block is information, but an order block that sits inside a discount zone, overlaps an active fair value gap, and forms after a liquidity sweep is a setup. Pulling those components from separate indicators forces a trader to eyeball alignment by hand. This script computes alignment directly:
— Order blocks are scored 0–100 based on size, displacement at creation, volume, and overlap with any active FVG on the same side.
— Premium/Discount is anchored to the last major structural event (not the visible range), so confluence with structure is automatic.
— Sweep detection is referenced to actual minor pivots, so a sweep label only appears at structurally meaningful levels — levels where structural reactions often occur.
— Equal highs / lows highlight the liquidity pools that sweeps target.
The output is a single chart where these confluence elements appear together in one place.
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
IMPLEMENTATION NOTES
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
◆ Adaptive pivot engine
The default pivot detection confirms a swing only when price retraces by ATR × multiplier rather than after a fixed bar window. Pivot density adapts to volatility — fewer pivots on trending days, tighter ones on chop. A fixed-window mode is available for traders who prefer the classic approach.
◆ Order block quality filter
Instead of taking the last opposite candle before a break, the engine scans a 30-bar structural window and selects the most-extreme candle that passes three filters: body-to-range ratio ≥ 25%, range < 2.5 × ATR (no outlier candles), and above-average volume by a configurable multiplier. The volume filter is optional.
◆ Market Structure Shift vs Change of Character
When a CHoCH occurs, the breaking candle is checked for displacement (body size ≥ multiplier × ATR). Displacement breaks are labelled MSS, non-displacement reversals stay labelled CHoCH. This separates impulsive trend reversals from soft ones.
◆ AVWAP-anchored Premium/Discount
Equilibrium is computed as a volume-weighted average price anchored at the last trend reversal (CHoCH/MSS), not as the midpoint of the visible range. The anchor resets only on a genuine trend change, so continuation BOSes do not invalidate the level. A classic range-midpoint mode is available as an alternative.
◆ Strict liquidity sweep detection
A sweep is flagged only if the wick pokes through a recent minor structural pivot (not a rolling max/min), the wick is at least 0.8 × ATR, the wick is at least 35% of the candle's total range, and 8 bars have passed since the last same-direction sweep. This significantly reduces signal frequency compared to simple wick-based detection without pivot reference or cooldown.
◆ Fair Value Gap fade mode
When an FVG is mitigated, it can either be removed (classic behaviour) or rendered semi-transparent so historical imbalances and price reactions remain visible. An ATR-based minimum size filter removes micro-gaps.
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
CONFLUENCE SCORE
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Each order block carries an optional 0–100 score:
— Size contribution (0–30): zone height relative to ATR
— Displacement contribution (0–30): body size of the breaking candle relative to ATR
— Volume contribution (10–20): above-average volume at zone creation
— FVG overlap (0–20): an active fair value gap of the same side intersects the zone
The score appears as a small label on each zone when enabled. A minimum-score filter hides everything below a chosen threshold.
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
HOW TO USE
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Start on a 1D chart with default settings. Use the major structure (BOS / CHoCH / MSS) to set bias. The setup the scoring system is designed to surface is a high-score order block inside a discount zone, overlapping an FVG, formed after a liquidity sweep. For timeframes below 4H, increase the pivot ATR multiplier to 2.5–3.0 to reduce noise.
Live display mode keeps only the most recent structural elements on the chart. All History mode keeps the full archive — useful for visual backtesting, but slower.
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
COMPONENTS AND SETTINGS
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
— Major and minor market structure: BOS, CHoCH, MSS, iBOS, iCHoCH
— Adaptive ZigZag or fixed-window pivot engine
— Order blocks with quality filter, wick or close mitigation
— Fair value gaps with optional fade mode and ATR size filter
— Equal highs / equal lows with ATR-based tolerance
— Liquidity sweeps with cooldown between same-direction signals
— Premium / Discount via AVWAP or range midpoint
— Previous day / week / month highs, lows, and midpoints
— Mono or accent colour themes
— Optional bar painting by minor bias
— Alerts on every structural and signal event
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
NOTES
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Smart Money Concepts methodology is public trading theory from Michael Huddleston (Inner Circle Trader). The implementation here — adaptive pivot engine, quality-filtered order blocks, AVWAP-anchored premium/discount, scoring system, and strict sweep detection — is independent work.
Feedback and bug reports welcome in the comments.
Wskaźnik Pine Script®






















