Expand description
Structure & SMC (Smart Money Concepts) Suite
High-performance, streaming-first implementation of Smart Money Concepts (SMC) and Market Structure analytics for algorithmic trading and quantitative research.
§Included Detectors
-
Choch/ChochDetector: Market Structure Break (BOS) and Change of Character (CHoCH) detector. Tracks swing highs and swing lows via a symmetric sliding window, determines structural trend (Bullish, Bearish, Undetermined), and emits rich break events:- BOS (Break of Structure): Continuation of current trend (e.g., closing above previous swing high in an uptrend, or below previous swing low in a downtrend).
- CHoCH (Change of Character): Reversal of structure (e.g., closing below previous swing low in an uptrend, or above previous swing high in a downtrend).
-
OrderBlock/OrderBlockDetector: Institutional Order Block (OB) detector with lifecycle mitigation tracking:- Bullish Order Block: The last down-closing candle prior to a strong bullish
breakout/displacement. Zone covers
[low, high](or body). - Bearish Order Block: The last up-closing candle prior to a strong bearish
breakdown/displacement. Zone covers
[low, high](or body). - Tracks incoming price action against active order blocks: unmitigated, partially mitigated (tested), and fully mitigated (violated / invalidated).
- Bullish Order Block: The last down-closing candle prior to a strong bullish
breakout/displacement. Zone covers
-
FairValueGap/FairValueGapDetector: 3-bar price imbalance detector (Fair Value Gap / FVG):- Bullish FVG:
low[t] > high[t - 2]. Imbalance zone is[high[t - 2], low[t]]. - Bearish FVG:
high[t] < low[t - 2]. Imbalance zone is[high[t], low[t - 2]]. - Tracks retest penetration and full mitigation as subsequent candles fill the imbalance.
- Bullish FVG:
§Formulas and References
-
CHoCH / BOS: Canonical SMC market structure: $$ \begin{aligned} \text{SwingHigh}t &= \operatorname{high}t \ge \operatorname{high}{t \pm i}, \quad \forall i \in [1, L] \ \text{SwingLow}t &= \operatorname{low}t \le \operatorname{low}{t \pm i}, \quad \forall i \in [1, L] \ \text{BOS}{\text{bull}} &= \text{Close} > \text{SwingHigh} \quad (\text{Trend} = \text{Bullish}) \ \text{CHoCH}{\text{bear}} &= \text{Close} < \text{SwingLow} \quad (\text{Trend} = \text{Bullish} \to \text{Bearish}) \end{aligned} $$ Source: https://www.tradingview.com/support/solutions/43000703076-market-structure/
-
Order Blocks: Institutional footprints preceding displacement moves: $$ \text{Bullish OB} = \text{Candle}_{t-1} (\text{Close} \le \text{Open}) \land \text{Close}t > \text{High}{t-1} $$ Source: https://www.tradingview.com/support/solutions/43000703077-order-blocks/
-
Fair Value Gaps: 3-bar price imbalance / liquidity voids: $$ \text{Bullish FVG} = \text{Low}t > \text{High}{t-2}, \quad \text{Bearish FVG} = \text{High}t < \text{Low}{t-2} $$ Source: https://www.tradingview.com/support/solutions/43000703078-fair-value-gaps/
Structs§
- Choch
- Market Structure detector tracking Swings, BOS, and CHoCH.
- Choch
State - Snapshot output of the Market Structure (CHoCH / BOS) detector.
- Fair
Value Gap - 3-bar Fair Value Gap (FVG) detector with lifecycle fill tracking.
- Fair
Value GapZone - Structural representation of an identified Fair Value Gap.
- FvgState
- Snapshot output of the Fair Value Gap detector.
- Order
Block - Institutional Order Block detector with lifecycle mitigation tracking.
- Order
Block Config - Tunable parameters for Order Block detection.
- Order
Block State - Snapshot output of the Order Block detector.
- Order
Block Zone - Structural representation of an identified Order Block.
- SmcSwing
Point - Confirmed swing extreme with bar index and price level.
- Structure
Break Event - Structural break event emitted when price closes beyond an active swing level.
Enums§
- FvgDirection
- Direction of price imbalance for Fair Value Gaps.
- Mitigation
Status - Mitigation status for order blocks and fair value gaps.
- Order
Block Type - Order block classification.
- Order
Block Zone Mode - Calculation mode for the order block price zone boundaries.
- Structure
Break Direction - Direction of structure break.
- Structure
Break Type - Category of structure break.
- Structure
Trend - Structural market trend derived from swing highs and swing lows.
- Swing
Type - Type of swing extreme.
Constants§
Functions§
- choch_
batch - Compute
Chochover a batch of(high, low, close)bars. - fair_
value_ gap_ batch - Compute
FairValueGapover a batch of(high, low, close)bars. - order_
block_ batch - Compute
OrderBlockover a batch of(open, high, low, close)bars.