smart-money-concepts

A TypeScript implementation of Smart Money Concepts (ICT methodology) for market structure analysis. Detects order blocks, fair value gaps, breaks of structure, changes of character, liquidity grabs, and more.

Zero runtime dependencies. Feed it OHLCV candles, get back structured market analysis.

typescript zero-deps ict smc

Installation

bun install smart-money-concepts

Quick Start

import { SmartMoneyConcepts } from 'smart-money-concepts'

const smc = new SmartMoneyConcepts({
  swingsLengthInput: 50,
})

// Feed candles one at a time
const alerts = smc.update(high, low, open, close, timestamp, volume)

// Check what happened
if (alerts.swingBullishBOS) {
  console.log('Bullish Break of Structure detected')
}

if (alerts.swingBearishCHoCH) {
  console.log('Bearish Change of Character detected')
}

// Get current market state
const bias = smc.getTrendBias()      // 'Bullish' | 'Bearish' | 'Neutral'
const zone = smc.getCurrentZone()     // 'Premium' | 'Discount' | 'Equilibrium'
const obs  = smc.getOrderBlocks()    // { swing, internal }

Bulk Processing

For backtesting, pass an array of candles at once:

const candles = [
  { time: 1700000000, open: 100, high: 105, low: 98, close: 103, volume: 1000 },
  { time: 1700000060, open: 103, high: 108, low: 101, close: 106, volume: 1200 },
  // ...
]

const allAlerts = smc.updateBulk(candles)

Real-Time Updates

When streaming live data, the same timestamp is treated as an update to the current bar:

// New bar
smc.update(105, 100, 102, 104, 1700000000, 500)

// Same timestamp = updates the current bar in place
smc.update(107, 100, 102, 106, 1700000000, 800)

// New timestamp = new bar
smc.update(108, 103, 106, 107, 1700000060, 600)

What It Detects

API Reference

Core Methods

Method Returns Description
update() Alerts Process a new candle. Auto-detects updates to current bar.
updateLastBar() Alerts Explicitly update the last bar in place.
updateBulk() Alerts[] Process an array of candles at once.
clearAllData() void Reset all internal state.

Market State

Method Returns Description
getTrendBias() TrendBias Swing trend: Bullish, Bearish, or Neutral
getInternalBias() TrendBias Internal (shorter-term) trend direction
getCurrentZone() Zone Premium, Discount, or Equilibrium
getOrderBlocks() { swing, internal } Active order blocks at both levels
getMarketMakerAnalysis() MarketMakerAnalysis Wyckoff phase with confidence score
getOrderFlowSignals() OrderFlowSignal[] Recent institutional activity signals
getLiquidityGrabs() LiquidityGrab[] Recent liquidity grab events

Alerts

Every call to update() returns an Alerts object. Use alerts.getTrueAlerts() to get only active alerts.

Structure

  • swingBullishBOS / swingBearishBOS — Swing Break of Structure
  • swingBullishCHoCH / swingBearishCHoCH — Swing Change of Character
  • internalBullishBOS / internalBearishBOS — Internal Break of Structure
  • internalBullishCHoCH / internalBearishCHoCH — Internal Change of Character

Order Blocks

  • swingBullishObBrokenDown / swingBearishObBrokenUp — Swing OB mitigation
  • internalBullishObBrokenDown / internalBearishObBrokenUp — Internal OB mitigation
  • insideSwingBullishOrderBlock / insideSwingBearishOrderBlock — Price inside swing OB
  • insideInternalBullishOrderBlock / insideInternalBearishOrderBlock — Price inside internal OB

Other

  • equalHighs / equalLows — Equal highs/lows (liquidity pools)
  • bullishFairValueGap / bearishFairValueGap — FVG detection
  • liquidityGrab — Liquidity grab at equal levels
  • volumeSpike / institutionalVolume — Volume events
  • breakerBlockFormed — HP OB failed, became breaker
  • unicornSetup — Breaker + FVG alignment

Configuration

const smc = new SmartMoneyConcepts({
  // Structure detection
  swingsLengthInput: 50,              // Bars to confirm swing pivots
  equalHighsLowsLengthInput: 3,      // Bars to confirm equal highs/lows
  equalHighsLowsThresholdInput: 0.1, // Sensitivity (0-0.5)

  // Order blocks
  internalOrderBlocksSizeInput: 5,    // Max internal OBs to track
  swingOrderBlocksSizeInput: 5,       // Max swing OBs to track
  orderBlockFilterInput: 'Atr',       // 'Atr' | 'Cumulative Mean Range'
  orderBlockMitigationInput: 'Close', // 'Close' | 'High/Low'

  // Volume
  volumeThresholdInput: 1.2,          // Volume spike threshold
  requireVolumeConfirmation: false,  // Require volume for signals

  // ICT methodology
  onlyTradeFreshOBs: true,            // Only fresh (unmitigated) OBs
  maxOBMitigations: 1,               // Max times an OB can be traded
  enableCOSD: true,                   // Change of State of Delivery
  classifyOrderBlocks: true,          // HP vs Continuation classification

  // ATR period
  atrPeriod: 200,                     // ATR calculation period
})

Custom Logger

Debug output is silenced by default. Plug in your own logger:

import { setLogger } from 'smart-money-concepts'

setLogger({
  debug: (msg, ...args) => console.debug(msg, ...args),
  warn:  (msg, ...args) => console.warn(msg, ...args),
  error: (msg, ...args) => console.error(msg, ...args),
})

Types

All types are exported from the package:

import {
  SmartMoneyConcepts,
  SmartMoneyConceptsConfig,
  Alerts,
  Candle,
  OrderBlock,
  OrderBlockType,
  FairValueGap,
  LiquidityGrab,
  TrendBias,
  Zone,
  MarketPhase,
  MarketMakerAnalysis,
  OrderFlowSignal,
  OrderFlowType,
  TradingSession,
  ConfluenceComponents,
  // ...and more
} from 'smart-money-concepts'

View full source on GitHub →