Indicator · Pine Script v5 · On the chart

SMC Entry Filter

by andriiops

This overlay indicator tracks confirmed swing highs and lows as liquidity levels and marks a break of structure when the close moves beyond the last swing.

View on GitHub

GitHub stars1on the repository
Pine versionv5runs as is
Lines of code57
Settings7inputs
LicenceMIT
Last update2 months ago17 Aug 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

57 lines of Pine Script v5 from pine/smc_entry_filter.pine, published under MIT. Keep the author's credit and licence lines when you reuse it.

smc_entry_filter.pine
//@version=5
indicator("SMC Entry Filter", overlay=true, max_boxes_count=50, max_lines_count=50)

// ICT / SMC research overlay: swings, BOS, FVG, hug-zone filter near key liquidity.
// Not a signal service. Use on liquid futures (ES / NQ 5m typical).

swingLen        = input.int(5, "Swing lookback", minval=2, maxval=20)
atrLen          = input.int(14, "ATR length")
fvgAtrFrac      = input.float(0.15, "Min FVG size (ATR)", minval=0.01, step=0.05)
hugAtrFrac      = input.float(0.25, "Hug zone (ATR) — skip entries this close to the broken level", minval=0.05, step=0.05)
dispAtrFrac     = input.float(0.35, "Displacement body (ATR)", minval=0.05, step=0.05)
nySessionOnly   = input.bool(true, "NY session only (09:30-16:00 ET)")
showFvg         = input.bool(true, "Draw FVG boxes")

atr = ta.atr(atrLen)

ph = ta.pivothigh(high, swingLen, swingLen)
pl = ta.pivotlow(low, swingLen, swingLen)

var float lastSwingHigh = na
var float lastSwingLow  = na
if not na(ph)
    lastSwingHigh := ph
if not na(pl)
    lastSwingLow := pl

inNy = not nySessionOnly or not na(time(timeframe.period, "0930-1600", "America/New_York"))

bullFvg = low > high[2] and (low - high[2]) >= atr * fvgAtrFrac
bearFvg = high < low[2] and (low[2] - high) >= atr * fvgAtrFrac

plotshape(showFvg and bullFvg, title="Bull FVG", style=shape.triangleup, location=location.belowbar, size=size.tiny, color=color.new(color.teal, 0))
plotshape(showFvg and bearFvg, title="Bear FVG", style=shape.triangledown, location=location.abovebar, size=size.tiny, color=color.new(color.maroon, 0))

bosUp = not na(lastSwingHigh) and close > lastSwingHigh and close[1] <= lastSwingHigh
bosDn = not na(lastSwingLow) and close < lastSwingLow and close[1] >= lastSwingLow

body = math.abs(close - open)
displaced = body >= atr * dispAtrFrac

hugHigh = not na(lastSwingHigh) and math.abs(close - lastSwingHigh) <= atr * hugAtrFrac
hugLow  = not na(lastSwingLow) and math.abs(close - lastSwingLow) <= atr * hugAtrFrac

longOk  = inNy and bosUp and close > open and displaced and not hugHigh
shortOk = inNy and bosDn and close < open and displaced and not hugLow

plot(lastSwingHigh, "Liquidity high", color=color.new(color.red, 40), style=plot.style_linebr)
plot(lastSwingLow, "Liquidity low", color=color.new(color.green, 40), style=plot.style_linebr)

plotshape(bosUp, "Raw BOS up", style=shape.circle, location=location.belowbar, size=size.tiny, color=color.new(color.gray, 30))
plotshape(bosDn, "Raw BOS down", style=shape.circle, location=location.abovebar, size=size.tiny, color=color.new(color.gray, 30))

plotshape(longOk, "Filtered long", style=shape.labelup, location=location.belowbar, text="L", size=size.small, color=color.new(color.teal, 0), textcolor=color.white)
plotshape(shortOk, "Filtered short", style=shape.labeldown, location=location.abovebar, text="S", size=size.small, color=color.new(color.maroon, 0), textcolor=color.white)

alertcondition(longOk, "SMC filtered long", "Filtered long: BOS up, displacement, not hugging liquidity high")
alertcondition(shortOk, "SMC filtered short", "Filtered short: BOS down, displacement, not hugging liquidity low")

Overview

SMC Entry Filter detects bullish and bearish fair value gaps that meet a minimum ATR size, then plots filtered long and short labels only when the close is directional, the candle body meets a displacement threshold, price is not still hugging the broken level, and the optional New York session window is active. Raw breaks remain visible as circles, and alerts fire on the filtered signals. It is not a strategy and has no stop, target, or position size.

Details

Published by

andriiops on GitHub

Type

Indicator, Pine Script v5

Draws

On the price chart

Category

SMC / ICT / price action, Support & resistance, Breakout, Sessions & time

Markets

Indices

Timeframes

M1-M5

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

backtestingfuturespine-scriptpythonquanttradingview

Settings

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

SettingTypeDefaultVariable
Swing lookbackint5swingLen
ATR lengthint14atrLen
Min FVG size (ATR)float0.15fvgAtrFrac
Hug zone (ATR) — skip entries this close to the broken levelfloat0.25hugAtrFrac
Displacement body (ATR)float0.35dispAtrFrac
NY session only (09:30-16:00 ET)booltruenySessionOnly
Draw FVG boxesbooltrueshowFvg
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

6 stars

Apex Protocol - The SMC Engine is a comprehensive Smart Money Concepts indicator that overlays key market structure levels directly on the main price chart. It calculates internal and external market structures (BOS and MSS), Order Blocks, Fair Value Gaps (FVG

Indicator v5 SMC / ICT / price actionSupport & resistance Repaints
Updated 7 months ago · None stated GitHub repository of Apex Protocol v3.4 - The SMC Engine

Golden Bullet Strategy

by TradersPost
218 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 3 months ago · None stated GitHub repository of Golden Bullet Strategy

This indicator tracks smart money market structure directly on the price chart. It calculates dual-period swing highs and swing lows to detect Changes of Character (CHoCH), Breaks of Structure (BOS), inducements, and liquidity sweeps. When structural levels ar

Indicator v5 SMC / ICT / price actionSupport & resistance
Updated 1 year ago · Apache-2.0 GitHub repository of Market Structure with Inducements & Sweeps [LuxAlgo]

More indicators

Trade Your Charts With a Regulated Broker

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

Compare brokers