Indicator · Pine Script v6 · On the chart

ICT Setup Screener, Liquidity Sweep, MSS & FVG Scanner

by theonetrade

This indicator monitors up to twenty instruments simultaneously for Inner Circle Trader (ICT) market structure patterns.

View on GitHub

GitHub stars34on the repository
Pine versionv6current
Lines of code506
Settings37inputs
LicenceMIT
Last update2 weeks ago8 Nov 2026

Add It to Your TradingView Chart

  1. 1Copy the scriptPress Copy script above, or the copy button on the code below.
  2. 2Open the Pine EditorOpen a TradingView chart and choose Pine Editor at the bottom of the screen.
  3. 3Paste over the templateCreate a new indicator, select all of the template text and paste. Press Save and give it a name.
  4. 4Add it to the chartPress Add to chart, then adjust the settings with the gear icon next to its name.

Source Code

506 lines of Pine Script v6 from assets/indicator/bit-exact/ict_setup_screener_liquidity_sweep_mss_fvg_scanner_lunqfx_6g7YF3N1.pine, published under MIT. Keep the author's credit and licence lines when you reuse it.

ict_setup_screener_liquidity_sweep_mss_fvg_scanner_lunqfx_6g7YF3N1.pine
//@version=6
// ============================================================================
//  ICT Setup Screener — Liquidity Sweep, MSS & FVG Scanner, 20 Symbols [LunqFX]
// ----------------------------------------------------------------------------
//  An ICT entry is a SEQUENCE, not a signal: liquidity is swept, structure
//  shifts, the displacement leaves an imbalance, price returns to it. Watching
//  one chart you see one instrument's sequence. This tool runs the same
//  sequence on twenty instruments at once and ranks them by how far along
//  each one is — so the question "where is a setup forming right now" is
//  answered by one table instead of twenty tabs.
//
//  Every row is a state machine on its own symbol:
//
//      SCANNING  →  SWEPT (waiting for the shift)  →  SETUP (MSS confirmed,
//      FVG entry mapped)  →  OPEN (price has returned into the imbalance)  →
//      TARGET or STOPPED
//
//  Rows are sorted live, hottest first. Quality 0-100 grades each setup by
//  sweep depth, displacement, FVG size and how fast the shift came.
//
//  NON-REPAINTING: swings are confirmed pivots and every transition happens
//  on a closed bar of the scan timeframe. A row never walks back a stage.
// ============================================================================
indicator("ICT Setup Screener, Liquidity Sweep, MSS & FVG Scanner [LunqFX]",
     "ICT Screener", overlay = true)

// ─────────────────────────────────────────────────────────────────────────
//  PALETTE
// ─────────────────────────────────────────────────────────────────────────
UP    = #00F5D4
DN    = #FF2E88
AMBER = #FBBF24
INK   = #0B0E14
CARD  = #131A24
CARD2 = #1B2431
TXT   = #F1F5F9
MUTE  = #94A3B8
DIMTX = #5B6B80

// ─────────────────────────────────────────────────────────────────────────
//  INPUTS
// ─────────────────────────────────────────────────────────────────────────
gM      = "Entry model"
scanTF  = input.timeframe("", "Scan timeframe", group = gM, tooltip = "Blank = the chart's timeframe. Set a fixed one (15, 60) so the table reads the same on any chart you open. Rows on a higher timeframe update when that timeframe's bar closes.")
pivLen  = input.int(8,  "Liquidity swing length", minval = 2, maxval = 50, group = gM, tooltip = "Which swings hold the stops that get swept. Higher = only major liquidity.")
intLen  = input.int(3,  "Internal structure length", minval = 1, maxval = 20, group = gM, tooltip = "The short-term swing whose break confirms the shift after the sweep.")
maxWait = input.int(20, "Max bars sweep → MSS", minval = 3, maxval = 100, group = gM, tooltip = "If structure does not shift within this many bars the sweep is discarded.")
lifeN   = input.int(30, "Max bars setup → entry", minval = 3, maxval = 200, group = gM, tooltip = "A mapped setup that price never returns to within this many bars is dropped.")
openN   = input.int(80, "Max bars in trade", minval = 5, maxval = 500, group = gM, tooltip = "An entered setup that has touched neither stop nor target within this many bars is retired from the table. The screener is for finding setups, not for babysitting a position for a week.")
rrMult  = input.float(2.0, "Take profit (R)", minval = 0.5, maxval = 10, step = 0.5, group = gM)
minRisk = input.float(0.20, "Min stop distance (× ATR)", minval = 0.0, maxval = 2.0, step = 0.05, group = gM)
minQual = input.int(0, "Hide setups below quality", minval = 0, maxval = 90, group = gM)

gW1 = "Watchlist  1 – 10"
s01 = input.symbol("OANDA:EURUSD", "1",  group = gW1)
s02 = input.symbol("OANDA:GBPUSD", "2",  group = gW1)
s03 = input.symbol("OANDA:USDJPY", "3",  group = gW1)
s04 = input.symbol("OANDA:AUDUSD", "4",  group = gW1)
s05 = input.symbol("OANDA:USDCAD", "5",  group = gW1)
s06 = input.symbol("OANDA:XAUUSD", "6",  group = gW1)
s07 = input.symbol("OANDA:XAGUSD", "7",  group = gW1)
s08 = input.symbol("OANDA:NZDUSD", "8",  group = gW1)
s09 = input.symbol("OANDA:USDCHF", "9",  group = gW1)
s10 = input.symbol("OANDA:EURGBP", "10", group = gW1)
gW2 = "Watchlist  11 – 20"
s11 = input.symbol("BINANCE:BTCUSDT", "11", group = gW2)
s12 = input.symbol("BINANCE:ETHUSDT", "12", group = gW2)
s13 = input.symbol("BINANCE:SOLUSDT", "13", group = gW2)
s14 = input.symbol("CME_MINI:ES1!",   "14", group = gW2)
s15 = input.symbol("CME_MINI:NQ1!",   "15", group = gW2)
s16 = input.symbol("TVC:DXY",         "16", group = gW2)
s17 = input.symbol("TVC:NDX",         "17", group = gW2)
s18 = input.symbol("TVC:SPX",         "18", group = gW2)
s19 = input.symbol("OANDA:EURJPY",    "19", group = gW2)
s20 = input.symbol("OANDA:GBPJPY",    "20", group = gW2)
nRows = input.int(20, "Rows in use", minval = 1, maxval = 20, group = gW2, tooltip = "Only the first N symbols are scanned and shown. Lower it for a shorter table.")

gV      = "Visuals"
candSty = input.string("Neon Bloom", "Candle palette", options = ["Neon Bloom","Midnight Cyan","Vibrant Neon","Classic Soft","Cool Blue","Off"], group = gV)
hudPos  = input.string("Top Right", "Table position", options = ["Top Right","Top Left","Bottom Right","Bottom Left","Middle Right","Middle Left"], group = gV)
hudSize = input.string("Normal", "Table text", options = ["Small","Normal","Large"], group = gV)
drawMe  = input.bool(true, "Draw this chart's setup", group = gV, tooltip = "The sequence is also run on the chart you are looking at and its live stage is drawn on the candles: the swept level, the shift level, the entry with stop and target. Twenty rows in the table, one setup on the chart.")
hideIdle= input.bool(false, "Hide SCANNING rows", group = gV, tooltip = "Show only symbols with something in progress.")
alertOn = input.bool(true, "Alert on new setup / entry", group = gV, tooltip = "Fires one alert per bar naming the symbol and stage. Create the alert with 'Any alert() function call'.")
alertSw = input.bool(true, "Also alert on sweep", group = gV, tooltip = "An early heads-up when liquidity is swept, before the shift confirms. Not every sweep becomes a setup — it tells you which chart to open.")

// ─────────────────────────────────────────────────────────────────────────
//  THE ENTRY MODEL AS A FUNCTION
//  Runs inside request.security, once per symbol. All state is per call site,
//  which is what makes twenty independent state machines possible from one
//  body of code. Nothing here draws — it only reports.
//
//  Stages:  0 scanning · 1 swept · 2 setup mapped · 3 in entry · 4 target ·
//           5 stopped
// ─────────────────────────────────────────────────────────────────────────
scan() =>
    atr = ta.atr(14)
    ph  = ta.pivothigh(pivLen, pivLen)
    pl  = ta.pivotlow(pivLen, pivLen)
    iph = ta.pivothigh(intLen, intLen)
    ipl = ta.pivotlow(intLen, intLen)

    var float swHigh = na
    var float swLow  = na
    var bool  hiTaken = false
    var bool  loTaken = false
    if not na(ph)
        swHigh  := ph
        hiTaken := false
    if not na(pl)
        swLow   := pl
        loTaken := false

    var float intHigh = na
    var float intLow  = na
    if not na(iph)
        intHigh := iph
    if not na(ipl)
        intLow := ipl

    var int   stage    = 0
    var int   dir      = 0
    var float sweepExt = na
    var float sweptLvl = na
    var float mssLevel = na
    var int   waited   = 0
    var int   age      = 0          // bars in the current stage
    var float entry    = na
    var float sl       = na
    var float tp       = na
    var int   qual     = 0
    var int   holdN    = 0          // bars a terminal state stays visible

    if barstate.isconfirmed
        age += 1

        // terminal states hold for a few bars, then the row goes back to work
        if stage >= 4
            holdN += 1
            if holdN > 8
                stage := 0
                dir   := 0
                age   := 0

        // ── 0 → 1 : liquidity sweep, wick through and close back inside ──
        if stage == 0
            if not na(swLow) and not loTaken and low < swLow and close > swLow and not na(intHigh) and intHigh > close
                loTaken := true
                stage := 1
                dir := 1
                sweepExt := low
                sweptLvl := swLow
                mssLevel := intHigh
                waited := 0
                age := 0
            else if not na(swHigh) and not hiTaken and high > swHigh and close < swHigh and not na(intLow) and intLow < close
                hiTaken := true
                stage := 1
                dir := -1
                sweepExt := high
                sweptLvl := swHigh
                mssLevel := intLow
                waited := 0
                age := 0

        // ── 1 → 2 : market structure shift confirms the sweep ──
        else if stage == 1
            waited += 1
            // a close beyond the sweep's own extreme means the stops were not
            // rejected, they were run through — the sweep has failed
            failed = dir == 1 ? close < sweepExt : close > sweepExt
            if waited > maxWait or failed
                stage := 0
                dir := 0
                age := 0
            else if (dir == 1 and close > mssLevel) or (dir == -1 and close < mssLevel)
                // the imbalance belongs to the displacement leg, so it is close by
                fvgT = 0.0
                fvgB = 0.0
                fvgAt = -1
                span = math.min(waited + 4, 18)
                for j = 0 to span
                    if fvgAt < 0
                        if dir == 1 and low[j] > high[j + 2]
                            fvgT := low[j]
                            fvgB := high[j + 2]
                            fvgAt := j
                        if dir == -1 and high[j] < low[j + 2]
                            fvgT := low[j + 2]
                            fvgB := high[j]
                            fvgAt := j
                e = fvgAt >= 0 ? (dir == 1 ? fvgT : fvgB) : mssLevel
                s = sweepExt
                risk = math.abs(e - s)
                a = math.max(nz(atr), syminfo.mintick)
                depth  = math.abs(sweepExt - sweptLvl) / a
                disp   = math.abs(close - mssLevel) / a
                fSize  = fvgAt >= 0 ? math.abs(fvgT - fvgB) / a : 0.0
                q = int(math.round(0.30 * math.min(1.0, depth / 0.45) * 100 + 0.30 * math.min(1.0, disp / 1.20) * 100 + 0.25 * math.min(1.0, fSize / 0.40) * 100 + 0.15 * math.max(0.0, 1.0 - waited / float(maxWait)) * 100))
                valid = risk > a * minRisk and (dir == 1 ? e > s : e < s) and q >= minQual
                if valid
                    stage := 2
                    entry := e
                    sl := s
                    tp := dir == 1 ? e + risk * rrMult : e - risk * rrMult
                    qual := q
                    age := 0
                else
                    stage := 0
                    dir := 0
                    age := 0

        // ── 2 → 3 : price returns into the entry ──
        else if stage == 2
            // a close through the stop before the entry was ever reached
            // invalidates the setup — there is nothing left to return to
            broken = dir == 1 ? close < sl : close > sl
            if age > lifeN or broken
                stage := 0
                dir := 0
                age := 0
            else if (dir == 1 and low <= entry) or (dir == -1 and high >= entry)
                stage := 3
                age := 0
                holdN := 0

        // ── 3 → 4 / 5 : the trade resolves ──
        else if stage == 3
            hitSL = dir == 1 ? low <= sl : high >= sl
            hitTP = dir == 1 ? high >= tp : low <= tp
            // stop is checked first: a bar that spans both is a loss, not a
            // win — the honest reading when the order of fills is unknown
            if hitSL
                stage := 5
                holdN := 0
                age := 0
            else if hitTP
                stage := 4
                holdN := 0
                age := 0
            else if age > openN
                stage := 0
                dir := 0
                age := 0

    // before the entry: how far away price is, in that instrument's ATR.
    // after it: how the trade stands, in R — the only unit twenty different
    // instruments share.
    risk0 = math.abs(entry - sl)
    toEn  = dir == 1 ? close - entry : entry - close
    prog  = stage == 3 and risk0 > 0 ? toEn / risk0 : na(entry) or na(atr) or atr == 0 ? na : toEn / atr
    // for idle rows: how far the nearest untaken liquidity sits, in ATR
    // a level price has already closed through is not liquidity any more,
    // even if it was never swept in the wick-and-reject sense
    liqUp = na(swHigh) or hiTaken or close > swHigh or na(atr) or atr == 0 ? na : (swHigh - close) / atr
    liqDn = na(swLow)  or loTaken or close < swLow  or na(atr) or atr == 0 ? na : (close - swLow) / atr
    [stage, dir, age, qual, entry, sl, tp, prog, liqUp, liqDn, sweptLvl, mssLevel]

// ─────────────────────────────────────────────────────────────────────────
//  TWENTY SYMBOLS, TWENTY MACHINES
//  One request per symbol, plus one for the chart itself: twenty-one of the
//  forty requests a script is allowed.
// ─────────────────────────────────────────────────────────────────────────
tf = scanTF == "" ? timeframe.period : scanTF
[st01, d01, a01, q01, e01, l01, t01, x01, u01, n01, w01, m01] = request.security(s01, tf, scan(), lookahead = barmerge.lookahead_off)
[st02, d02, a02, q02, e02, l02, t02, x02, u02, n02, w02, m02] = request.security(s02, tf, scan(), lookahead = barmerge.lookahead_off)
[st03, d03, a03, q03, e03, l03, t03, x03, u03, n03, w03, m03] = request.security(s03, tf, scan(), lookahead = barmerge.lookahead_off)
[st04, d04, a04, q04, e04, l04, t04, x04, u04, n04, w04, m04] = request.security(s04, tf, scan(), lookahead = barmerge.lookahead_off)
[st05, d05, a05, q05, e05, l05, t05, x05, u05, n05, w05, m05] = request.security(s05, tf, scan(), lookahead = barmerge.lookahead_off)
[st06, d06, a06, q06, e06, l06, t06, x06, u06, n06, w06, m06] = request.security(s06, tf, scan(), lookahead = barmerge.lookahead_off)
[st07, d07, a07, q07, e07, l07, t07, x07, u07, n07, w07, m07] = request.security(s07, tf, scan(), lookahead = barmerge.lookahead_off)
[st08, d08, a08, q08, e08, l08, t08, x08, u08, n08, w08, m08] = request.security(s08, tf, scan(), lookahead = barmerge.lookahead_off)
[st09, d09, a09, q09, e09, l09, t09, x09, u09, n09, w09, m09] = request.security(s09, tf, scan(), lookahead = barmerge.lookahead_off)
[st10, d10, a10, q10, e10, l10, t10, x10, u10, n10, w10, m10] = request.security(s10, tf, scan(), lookahead = barmerge.lookahead_off)
[st11, d11, a11, q11, e11, l11, t11, x11, u11, n11, w11, m11] = request.security(s11, tf, scan(), lookahead = barmerge.lookahead_off)
[st12, d12, a12, q12, e12, l12, t12, x12, u12, n12, w12, m12] = request.security(s12, tf, scan(), lookahead = barmerge.lookahead_off)
[st13, d13, a13, q13, e13, l13, t13, x13, u13, n13, w13, m13] = request.security(s13, tf, scan(), lookahead = barmerge.lookahead_off)
[st14, d14, a14, q14, e14, l14, t14, x14, u14, n14, w14, m14] = request.security(s14, tf, scan(), lookahead = barmerge.lookahead_off)
[st15, d15, a15, q15, e15, l15, t15, x15, u15, n15, w15, m15] = request.security(s15, tf, scan(), lookahead = barmerge.lookahead_off)
[st16, d16, a16, q16, e16, l16, t16, x16, u16, n16, w16, m16] = request.security(s16, tf, scan(), lookahead = barmerge.lookahead_off)
[st17, d17, a17, q17, e17, l17, t17, x17, u17, n17, w17, m17] = request.security(s17, tf, scan(), lookahead = barmerge.lookahead_off)
[st18, d18, a18, q18, e18, l18, t18, x18, u18, n18, w18, m18] = request.security(s18, tf, scan(), lookahead = barmerge.lookahead_off)
[st19, d19, a19, q19, e19, l19, t19, x19, u19, n19, w19, m19] = request.security(s19, tf, scan(), lookahead = barmerge.lookahead_off)
[st20, d20, a20, q20, e20, l20, t20, x20, u20, n20, w20, m20] = request.security(s20, tf, scan(), lookahead = barmerge.lookahead_off)

// ─────────────────────────────────────────────────────────────────────────
//  THE CHART'S OWN SETUP
//  A twenty-first run of the same sequence, on the chart itself, drawn live.
//  Six drawings, redrawn each bar, so the chart always shows the current
//  stage and nothing older — the table is the history, the chart is now.
// ─────────────────────────────────────────────────────────────────────────
// requested through the same path as the twenty rows, on the same scan
// timeframe, so the chart and its ◂ row can never disagree
[cSt, cDir, cAge, cQ, cEn, cSl, cTp, cPr, cLu, cLd, cSw, cMs] = request.security(syminfo.tickerid, tf, scan(), lookahead = barmerge.lookahead_off)

// the bar the current sequence began on — the sweep bar
var int cStart = na
if cSt == 1 and cSt[1] != 1
    cStart := bar_index
if cSt == 0
    cStart := na

var line  gSweep = na
var line  gMss   = na
var line  gEntry = na
var box   gRisk  = na
var box   gReward= na
var label gTag   = na

if drawMe and barstate.islast
    line.delete(gSweep)
    line.delete(gMss)
    line.delete(gEntry)
    box.delete(gRisk)
    box.delete(gReward)
    label.delete(gTag)
    if cSt >= 1 and cSt <= 3 and not na(cStart)
        col = cDir == 1 ? UP : DN
        x0  = math.max(cStart, bar_index - 300)
        x1  = bar_index + 6
        gSweep := line.new(x0, cSw, x1, cSw, color = color.new(AMBER, 10), width = 2, style = line.style_dotted)
        gMss   := line.new(x0, cMs, x1, cMs, color = color.new(col, 0), width = 2)
        if cSt >= 2
            gEntry  := line.new(x0, cEn, x1, cEn, color = color.new(TXT, 10), width = 2, style = line.style_dashed)
            gRisk   := box.new(x0, math.max(cEn, cSl), x1, math.min(cEn, cSl), border_color = color.new(DN, 55), bgcolor = color.new(DN, 90))
            gReward := box.new(x0, math.max(cEn, cTp), x1, math.min(cEn, cTp), border_color = color.new(UP, 55), bgcolor = color.new(UP, 90))
        arrow = cDir == 1 ? "▲ " : "▼ "
        tagTx = cSt == 1 ? arrow + "SWEPT · waiting MSS" : cSt == 2 ? arrow + (cDir == 1 ? "LONG" : "SHORT") + " SETUP · Q" + str.tostring(cQ) : arrow + "OPEN  " + (cPr >= 0 ? "+" : "") + str.tostring(cPr, "0.0") + " R"
        tagY  = cSt == 1 ? cSw : cEn
        gTag := label.new(x1, tagY, "  " + tagTx + "  ", style = label.style_label_left, color = INK, textcolor = cSt == 1 ? AMBER : col, size = size.normal)

// ─────────────────────────────────────────────────────────────────────────
//  CANDLES — neon pair, translucent body against a solid edge
// ─────────────────────────────────────────────────────────────────────────
cBull = switch candSty
    "Neon Bloom"    => #00F5D4
    "Midnight Cyan" => #34E89E
    "Vibrant Neon"  => #00E5B0
    "Classic Soft"  => #3FB68B
    "Cool Blue"     => #4C9AFF
    => #00F5D4
cBear = switch candSty
    "Neon Bloom"    => #FF2E88
    "Midnight Cyan" => #FF4D7D
    "Vibrant Neon"  => #FF2E63
    "Classic Soft"  => #E0556B
    "Cool Blue"     => #8A94A6
    => #FF2E88
cEdge = close >= open ? cBull : cBear
plotcandle(candSty == "Off" ? na : open, high, low, close, "Candles",
     color = color.new(cEdge, 24), wickcolor = color.new(cEdge, 18), bordercolor = cEdge)

// ─────────────────────────────────────────────────────────────────────────
//  HELPERS
// ─────────────────────────────────────────────────────────────────────────
hudP(string s) =>
    switch s
        "Top Right"     => position.top_right
        "Top Left"      => position.top_left
        "Bottom Right"  => position.bottom_right
        "Bottom Left"   => position.bottom_left
        "Middle Left"   => position.middle_left
        => position.middle_right

tSize(string s) =>
    switch s
        "Small" => size.small
        "Large" => size.large
        => size.normal

// "OANDA:EURUSD" → "EURUSD"
shortName(string s) =>
    p = str.pos(s, ":")
    p >= 0 ? str.substring(s, p + 1) : s

// lower rank = higher in the table: entries first, then mapped setups, then
// pending sweeps, then finished trades, then idle rows. Within a stage the
// freshest row wins.
rankOf(int stage, int age) =>
    base = stage == 3 ? 0 : stage == 2 ? 1 : stage == 1 ? 2 : stage == 4 ? 3 : stage == 5 ? 4 : 5
    base * 100000 + age

stageText(int stage, int dir) =>
    arrow = dir == 1 ? "▲ " : dir == -1 ? "▼ " : ""
    switch stage
        1 => arrow + "SWEPT · waiting MSS"
        2 => arrow + (dir == 1 ? "LONG SETUP" : "SHORT SETUP")
        3 => arrow + "OPEN"
        4 => arrow + "TARGET HIT"
        5 => arrow + "STOPPED"
        => "scanning"

stageBg(int stage, int dir) =>
    switch stage
        1 => #5A3E0A
        2 => dir == 1 ? #0A5F55 : #8E1148
        3 => dir == 1 ? #00A38B : #C21B5E
        4 => #14532D
        5 => #4A1020
        => CARD

// ─────────────────────────────────────────────────────────────────────────
//  TABLE
// ─────────────────────────────────────────────────────────────────────────
var table hud = table.new(position.top_right, 7, 22)

if barstate.islast
    // gather the twenty rows into arrays so they can be ranked
    syms  = array.from(s01, s02, s03, s04, s05, s06, s07, s08, s09, s10, s11, s12, s13, s14, s15, s16, s17, s18, s19, s20)
    stg   = array.from(st01, st02, st03, st04, st05, st06, st07, st08, st09, st10, st11, st12, st13, st14, st15, st16, st17, st18, st19, st20)
    dirs  = array.from(d01, d02, d03, d04, d05, d06, d07, d08, d09, d10, d11, d12, d13, d14, d15, d16, d17, d18, d19, d20)
    ages  = array.from(a01, a02, a03, a04, a05, a06, a07, a08, a09, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20)
    quals = array.from(q01, q02, q03, q04, q05, q06, q07, q08, q09, q10, q11, q12, q13, q14, q15, q16, q17, q18, q19, q20)
    ents  = array.from(e01, e02, e03, e04, e05, e06, e07, e08, e09, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20)
    sls   = array.from(l01, l02, l03, l04, l05, l06, l07, l08, l09, l10, l11, l12, l13, l14, l15, l16, l17, l18, l19, l20)
    tps   = array.from(t01, t02, t03, t04, t05, t06, t07, t08, t09, t10, t11, t12, t13, t14, t15, t16, t17, t18, t19, t20)
    dist  = array.from(x01, x02, x03, x04, x05, x06, x07, x08, x09, x10, x11, x12, x13, x14, x15, x16, x17, x18, x19, x20)
    lqU   = array.from(u01, u02, u03, u04, u05, u06, u07, u08, u09, u10, u11, u12, u13, u14, u15, u16, u17, u18, u19, u20)
    lqD   = array.from(n01, n02, n03, n04, n05, n06, n07, n08, n09, n10, n11, n12, n13, n14, n15, n16, n17, n18, n19, n20)

    ranks = array.new<int>()
    for i = 0 to nRows - 1
        array.push(ranks, rankOf(array.get(stg, i), array.get(ages, i)))
    ord = array.sort_indices(ranks, order.ascending)

    nEntry = 0
    nSetup = 0
    nSweep = 0
    for i = 0 to nRows - 1
        s = array.get(stg, i)
        nEntry += s == 3 ? 1 : 0
        nSetup += s == 2 ? 1 : 0
        nSweep += s == 1 ? 1 : 0

    table.delete(hud)
    hud := table.new(hudP(hudPos), 7, nRows + 2, bgcolor = CARD, border_color = color.new(#28323F, 0), border_width = 1)
    ts = tSize(hudSize)

    // hero row — what the whole list adds up to
    heroBg = nEntry > 0 ? #0A5F55 : nSetup > 0 ? #1E2A38 : CARD2
    heroTx = nEntry > 0 ? str.tostring(nEntry) + " OPEN" : nSetup > 0 ? str.tostring(nSetup) + " SETUP" + (nSetup > 1 ? "S" : "") + " MAPPED" : nSweep > 0 ? str.tostring(nSweep) + " SWEEP" + (nSweep > 1 ? "S" : "") + " PENDING" : "NO SETUPS · scanning " + str.tostring(nRows)
    table.cell(hud, 0, 0, "  ICT SETUP SCREENER  ·  " + heroTx + "  ", text_color = color.white, text_size = size.large, text_halign = text.align_left, bgcolor = heroBg)
    table.merge_cells(hud, 0, 0, 4, 0)
    table.cell(hud, 5, 0, str.tostring(nSetup) + (nSetup == 1 ? " setup · " : " setups · ") + str.tostring(nSweep) + (nSweep == 1 ? " sweep  " : " sweeps  "), text_color = color.white, text_size = size.normal, text_halign = text.align_right, bgcolor = heroBg)
    table.merge_cells(hud, 5, 0, 6, 0)

    // column headers
    hdr = array.from("  Symbol", "Stage", "Bars", "Quality", "Entry", "Stop  /  Target", "To entry · R · liquidity  ")
    for c = 0 to 6
        table.cell(hud, c, 1, array.get(hdr, c), text_color = MUTE, text_size = size.small, text_halign = c == 0 ? text.align_left : c == 6 ? text.align_right : text.align_center, bgcolor = CARD2)

    r = 2
    for k = 0 to nRows - 1
        i  = array.get(ord, k)
        s  = array.get(stg, i)
        d  = array.get(dirs, i)
        if not (hideIdle and s == 0)
            live = s >= 1 and s <= 3
            fg   = live ? TXT : s == 0 ? DIMTX : MUTE
            bg   = stageBg(s, d)
            rowBg = s == 0 ? CARD : CARD2
            en = array.get(ents, i)
            sp = array.get(sls, i)
            tg = array.get(tps, i)
            dx = array.get(dist, i)
            q  = array.get(quals, i)
            isMe = syminfo.ticker == shortName(array.get(syms, i))

            table.cell(hud, 0, r, "  " + shortName(array.get(syms, i)) + (isMe ? " ◂" : ""), text_color = isMe ? UP : fg, text_size = ts, text_halign = text.align_left, bgcolor = rowBg)
            table.cell(hud, 1, r, "  " + stageText(s, d) + "  ", text_color = s == 0 ? DIMTX : color.white, text_size = ts, text_halign = text.align_center, bgcolor = bg)
            table.cell(hud, 2, r, s == 0 ? "" : str.tostring(array.get(ages, i)), text_color = fg, text_size = ts, text_halign = text.align_center, bgcolor = rowBg)
            table.cell(hud, 3, r, s >= 2 ? "Q " + str.tostring(q) : "", text_color = s >= 2 ? (q >= 70 ? UP : q >= 45 ? AMBER : DN) : fg, text_size = ts, text_halign = text.align_center, bgcolor = rowBg)
            table.cell(hud, 4, r, s >= 2 and not na(en) ? str.tostring(en, "#.#####") : "", text_color = fg, text_size = ts, text_halign = text.align_center, bgcolor = rowBg)
            table.cell(hud, 5, r, s >= 2 and not na(sp) ? str.tostring(sp, "#.#####") + "  /  " + str.tostring(tg, "#.#####") : "", text_color = fg, text_size = ts, text_halign = text.align_center, bgcolor = rowBg)
            // distance reads in ATRs so twenty different instruments compare
            // idle rows are not dead rows: they show how far the nearest untaken
            // liquidity sits, which is where the next sweep can come from
            lu = array.get(lqU, i)
            ld = array.get(lqD, i)
            liqTx = na(lu) and na(ld) ? "" : (na(ld) or (not na(lu) and lu < ld)) ? "liq ▲ " + str.tostring(lu, "0.0") + " ATR" : "liq ▼ " + str.tostring(ld, "0.0") + " ATR"
            dxTx = s == 3 and not na(dx) ? (dx >= 0 ? "+" : "") + str.tostring(dx, "0.0") + " R" : s == 2 and not na(dx) ? (dx <= 0 ? "touching" : str.tostring(dx, "0.0") + " ATR") : s == 0 ? liqTx : ""
            dxCol = s == 3 and not na(dx) ? (dx >= 0 ? UP : DN) : s == 2 and not na(dx) and dx <= 0.5 ? AMBER : s == 0 ? DIMTX : fg
            table.cell(hud, 6, r, dxTx + "  ", text_color = dxCol, text_size = ts, text_halign = text.align_right, bgcolor = rowBg)
            r += 1

// ─────────────────────────────────────────────────────────────────────────
//  ALERTS — one message per bar, naming the symbol
// ─────────────────────────────────────────────────────────────────────────
// A stage is named the bar it changes. Comparing against the previous bar's
// stage — rather than a "fired" flag carried out of the request — is what
// keeps a higher scan timeframe from repeating the same alert on every chart
// bar until that timeframe's bar closes.
if alertOn and barstate.isconfirmed
    cur  = array.from(st01, st02, st03, st04, st05, st06, st07, st08, st09, st10, st11, st12, st13, st14, st15, st16, st17, st18, st19, st20)
    prev = array.from(st01[1], st02[1], st03[1], st04[1], st05[1], st06[1], st07[1], st08[1], st09[1], st10[1], st11[1], st12[1], st13[1], st14[1], st15[1], st16[1], st17[1], st18[1], st19[1], st20[1])
    ds   = array.from(d01, d02, d03, d04, d05, d06, d07, d08, d09, d10, d11, d12, d13, d14, d15, d16, d17, d18, d19, d20)
    qs   = array.from(q01, q02, q03, q04, q05, q06, q07, q08, q09, q10, q11, q12, q13, q14, q15, q16, q17, q18, q19, q20)
    ss   = array.from(s01, s02, s03, s04, s05, s06, s07, s08, s09, s10, s11, s12, s13, s14, s15, s16, s17, s18, s19, s20)
    msg = ""
    for i = 0 to nRows - 1
        c = array.get(cur, i)
        if c != array.get(prev, i) and (c == 2 or c == 3 or (alertSw and c == 1))
            side = array.get(ds, i) == 1 ? "long" : "short"
            msg := msg + shortName(array.get(ss, i)) + (c == 1 ? " swept, watch for " + side : c == 2 ? " " + side + " setup mapped Q" + str.tostring(array.get(qs, i)) : " " + side + " entered") + " · "
    if msg != ""
        alert("LunqFX ICT Screener: " + msg, alert.freq_once_per_bar_close)

Overview

ICT Setup Screener, Liquidity Sweep, MSS & FVG Scanner tracks a four-stage sequence: liquidity sweep, market structure shift (MSS), fair value gap (FVG) creation, and subsequent retest entry. Setups are evaluated and assigned a quality score from 0 to 100 based on displacement, swing depth, and shift speed. Results are presented in an on-chart dashboard table sorted by setup readiness. Inputs allow customizing the scan timeframe, swing pivot lengths, risk-reward ratios, and symbol lists.

Details

Published by

theonetrade on GitHub

Draws

On the price chart

Markets

Forex, Crypto, Indices, Gold, Oil & commodities

Timeframes

Any timeframe

Risk Notes

No repainting, lookahead or stacked entries were found in its code or README. That says nothing about how well it works: test it first.

Topics

algorithmic-tradingbacktestingbitcoinccxtcrypto-tradingllm-agentoffline-backtestingopen-source-tradingpine-scriptpine-to-pythonpinescriptpynecorepythonquantquantitative-financestrategy-backtestingtechnical-analysistrading-indicatorstrading-strategiestradingview

Settings

The inputs you can change from the gear icon on the chart. Defaults are the author's.

SettingTypeDefaultVariable
Scan timeframetimeframescanTF
Liquidity swing lengthint8pivLen
Internal structure lengthint3intLen
Max bars sweep → MSSint20maxWait
Max bars setup → entryint30lifeN
Max bars in tradeint80openN
Take profit (R)float2.0rrMult
Min stop distance (× ATR)float0.20minRisk
Hide setups below qualityint0minQual
1symbolOANDA:EURUSDs01
2symbolOANDA:GBPUSDs02
3symbolOANDA:USDJPYs03
Show all 37 settings
SettingTypeDefaultVariable
4symbolOANDA:AUDUSDs04
5symbolOANDA:USDCADs05
6symbolOANDA:XAUUSDs06
7symbolOANDA:XAGUSDs07
8symbolOANDA:NZDUSDs08
9symbolOANDA:USDCHFs09
10symbolOANDA:EURGBPs10
11symbolBINANCE:BTCUSDTs11
12symbolBINANCE:ETHUSDTs12
13symbolBINANCE:SOLUSDTs13
14symbolCME_MINI:ES1!s14
15symbolCME_MINI:NQ1!s15
16symbolTVC:DXYs16
17symbolTVC:NDXs17
18symbolTVC:SPXs18
19symbolOANDA:EURJPYs19
20symbolOANDA:GBPJPYs20
Rows in useint20nRows
Candle palettestringNeon BloomcandSty
Table positionstringTop RighthudPos
Table textstringNormalhudSize
Draw this chart's setupbooltruedrawMe
Hide SCANNING rowsboolfalsehideIdle
Alert on new setup / entrybooltruealertOn
Also alert on sweepbooltruealertSw
Third-party code. ForexR did not write, test or endorse this script, and the summary above was generated automatically from its code and README. Indicators describe the past, and a strategy's backtest can look better than live trading, especially when a script repaints. Check it in the Strategy Tester and on a demo account before you rely on it.

Similar Pine Scripts

575 stars

This overlay indicator scans a pasted list of symbols for ICT liquidity sweep patterns using prior swing sweeps. The screening method looks back one, two, or three swings and can list long and short signals in a results table with adjustable rows, position, an

Indicator v5 SMC / ICT / price actionScreeners & dashboards
Updated 1 year ago · MPL-2.0 GitHub repository of ICT Liquidity Sweep Pattern Scanner

Golden Bullet Strategy

by TradersPost
228 stars

The Golden Bullet Strategy is an overlay signal indicator based on Smart Money Concepts and time-based liquidity models. It identifies liquidity sweeps of a designated reference session range during a specified hunt window. It then confirms Market Structure Sh

Indicator v6 SMC / ICT / price actionSessions & time
Updated 4 months ago · None stated GitHub repository of Golden Bullet Strategy

Order Flow Strategy (OFS)

by roan-maverick
69 stars

The Order Flow Strategy is a chart overlay indicator based on auction market theory and order flow concepts. It evaluates higher-timeframe value structure across custom timeframes alongside value area profiles (VAH, POC, VAL) and Fibonacci discount or premium

Indicator v6 SMC / ICT / price actionSupport & resistance Repaints
Updated 10 days ago · Custom licence GitHub repository of Order Flow Strategy (OFS)
56 stars

This indicator identifies fractal-based pivot highs and lows to map out market structure directly on the price chart. It detects bullish and bearish structure breaks, automatically labeling Break of Structure (BOS) and Change of Character (ChoCH) events when p

Indicator v5 SMC / ICT / price actionSupport & resistance
Updated 3 months ago · None stated GitHub repository of Market Structure (Fractal)
53 stars

Apex Trend & Liquidity Master calculates a trend cloud using customizable moving averages expanded by a volatility multiplier directly on the main price chart. It identifies dynamic support and resistance liquidity zones from swing high and low pivots, extendi

Indicator v6 TrendSupport & resistance
Updated 3 months ago · MPL-2.0 GitHub repository of Apex Trend & Liquidity Master

More SMC / ICT scripts

Related on ForexR

Trade Your Charts With a Regulated Broker

Compare brokers that connect to TradingView, with spreads, minimum deposits and leverage side by side.

Compare brokers