Indicator · Pine Script v5 · On the chart

Pro SMC Fair Value Gap (FVG) Indicator

by xPhantom5

This indicator identifies bullish and bearish Fair Value Gaps (FVG) on the main price chart based on three-bar price imbalances.

View on GitHub

GitHub stars2on the repository
Pine versionv5runs as is
Lines of code54
Settings10inputs
LicenceGPL-3.0
Last update1 year ago5 May 2025

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

54 lines of Pine Script v5 from pro-smc-fvg-indicator.pine, published under GPL-3.0. Keep the author's credit and licence lines when you reuse it.

pro-smc-fvg-indicator.pine
//@version=5
indicator("🔥 Pro SMC Fair Value Gap (FVG) Indicator", overlay=true)

// === INPUTS === //
showBullishFVG = input.bool(true, "Show Bullish FVG")
showBearishFVG = input.bool(true, "Show Bearish FVG")
bullColor = input.color(color.new(color.green, 60), "Bullish FVG Fill")
bearColor = input.color(color.new(color.red, 60), "Bearish FVG Fill")
bullBorder = input.color(color.green, "Bullish FVG Border")
bearBorder = input.color(color.red, "Bearish FVG Border")
labelSize = input.string("small", "Label Size", options=["tiny", "small", "normal", "large", "huge"])
maxBoxes = input.int(100, "Max Boxes on Chart")
useStrongDisplacement = input.bool(true, "Use Displacement Filter (ATR-based)")
displacementMultiplier = input.float(1.5, "Displacement Strength", step=0.1)

// === CONDITIONS === //
body = math.abs(close - open)
displacement = body > ta.atr(14) * displacementMultiplier

isBullishFVG = low > high[2]
isBearishFVG = high < low[2]

validBullFVG = isBullishFVG and (not useStrongDisplacement or displacement)
validBearFVG = isBearishFVG and (not useStrongDisplacement or displacement)

// === STORAGE === //
var box[] fvgBoxes = array.new_box()
var label[] fvgLabels = array.new_label()

// === DRAWING === //
if showBullishFVG and validBullFVG
    b = box.new(left=bar_index[2], right=bar_index, top=low, bottom=high[2], bgcolor=bullColor, border_color=bullBorder)
    l = label.new(x=bar_index, y=low, text="Bullish FVG", style=label.style_label_up, textcolor=color.white, size=labelSize, color=color.green)
    array.push(fvgBoxes, b)
    array.push(fvgLabels, l)

if showBearishFVG and validBearFVG
    b = box.new(left=bar_index[2], right=bar_index, top=high[2], bottom=low, bgcolor=bearColor, border_color=bearBorder)
    l = label.new(x=bar_index, y=high, text="Bearish FVG", style=label.style_label_down, textcolor=color.white, size=labelSize, color=color.red)
    array.push(fvgBoxes, b)
    array.push(fvgLabels, l)

// === AUTO DELETE OLD OBJECTS === //
if array.size(fvgBoxes) > maxBoxes
    oldBox = array.shift(fvgBoxes)
    box.delete(oldBox)

if array.size(fvgLabels) > maxBoxes
    oldLabel = array.shift(fvgLabels)
    label.delete(oldLabel)

// === ALERTS === //
alertcondition(validBullFVG, title="Bullish FVG Detected", message="Bullish Fair Value Gap formed!")
alertcondition(validBearFVG, title="Bearish FVG Detected", message="Bearish Fair Value Gap formed!")

Overview

Pro SMC Fair Value Gap (FVG) Indicator features an optional ATR-based displacement filter to isolate gaps formed during strong market momentum. Detected gaps are displayed directly on the price chart as customizable colored fill boxes and text labels. Users can adjust display parameters, such as box colors, border colors, label sizes, displacement thresholds, and set a maximum limit on active chart boxes to maintain visual clarity.

Details

Published by

xPhantom5 on GitHub

Type

Indicator, Pine Script v5

Draws

On the price chart

Category

SMC / ICT / price action, Support & resistance, Volatility & bands

Markets

Any symbol

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.

Settings

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

SettingTypeDefaultVariable
Show Bullish FVGbooltrueshowBullishFVG
Show Bearish FVGbooltrueshowBearishFVG
Bullish FVG Fillcolorcolor.new(color.green, 60)bullColor
Bearish FVG Fillcolorcolor.new(color.red, 60)bearColor
Bullish FVG Bordercolorcolor.greenbullBorder
Bearish FVG Bordercolorcolor.redbearBorder
Label SizestringsmalllabelSize
Max Boxes on Chartint100maxBoxes
Use Displacement Filter (ATR-based)booltrueuseStrongDisplacement
Displacement Strengthfloat1.5displacementMultiplier
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

ICT Liquidity Void Fill

by ArunKBhaskar
575 stars

This overlay indicator marks ICT liquidity void fills on the price chart and can show long and short signals. It places a Fibonacci level inside a displacement candle, defaulting to the midpoint, and draws lines in a chosen style. Optional filters limit the fi

Indicator v6 SMC / ICT / price actionSupport & resistance
Updated 1 year ago · MPL-2.0 GitHub repository of ICT Liquidity Void Fill
218 stars

This indicator maps market structure and supply and demand zones on the price chart. It marks validated and optional unvalidated swing highs and lows using a pivot length and extra confirmation bars. Consolidation and impulse moves are measured against ATR to

Indicator v6 SMC / ICT / price actionSupport & resistance Repaints
Updated 3 months ago · None stated GitHub repository of Market Structure + Supply/Demand
55 stars

This Pine Script indicator overlays institutional liquidity levels on the price chart. It identifies order block levels using pivot highs and lows, then draws mean reversion lines from the 20 and 50 period simple moving averages, a volatility range midpoint pr

Indicator v6 Support & resistanceSMC / ICT / price action Repaints
Updated 6 months ago · Apache-2.0 GitHub repository of AAPL Institutional Liquidity Grid

This indicator combines six trading tools into a single chart overlay to optimize indicator limits. It calculates Bollinger Bands, projects weekend price boundaries, plots market structure elements like order blocks, breaker blocks, and MSB lines, marks New Yo

Indicator v6 Support & resistanceSMC / ICT / price action Repaints

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