Indicator · Pine Script v5 · On the chart

ICT Setup 01 TFlab

by alvinng214· code credited to TFlab

This indicator detects Fair Value Gaps using a multiplier factor and validity period.

View on GitHub

GitHub stars2on the repository
Pine versionv5runs as is
Lines of code387
Settings15inputs
LicenceNone statedfile: MPL-2.0
Last update2 months ago5 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

387 lines of Pine Script v5 from S1_Silver_Bullet/ICT Setup 01 [TradingFinder] FVG + Liquidity SweepsHunt Alerts, ICT Setup 01 TFlab.txt, published under MPL-2.0 (file header). Keep the author's credit and licence lines when you reuse it.

ICT Setup 01 [TradingFinder] FVG + Liquidity SweepsHunt Alerts, ICT Setup 01 TFlab.txt
// This Pine Script™ code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © TFlab

//@version=5
indicator("ICT Setup 01 [TradingFinder] FVG + Liquidity Sweeps/Hunt Alerts", "ICT Setup 01 TFlab", overlay = true, max_bars_back = 5000, max_labels_count = 500, max_lines_count = 500)

//import Library
    //Alert Sender Library
import TFlab/AlertSenderLibrary_TradingFinder/1 as AlertSender

//input
    //Multiplier Factor - Y length
MATR = input.float(1 , 'FVG Detector Multiplier Factor',minval = 1 ,tooltip = 'By raising this coefficient, FVGs are identified, which the' +  
 'market has moved more and faster at the moment of their formation.', group = 'FVGs Setting' )
    //Validity Period   - X length
ValLenFVG = input.int(15, 'FVG Validity Period',minval = 2,tooltip ='You can determine the validity period of each FVG based on the number of candles.'  , group = 'FVGs Setting')
    //FVG in the cheap or expensive or indifferent Zone
DisANDPre = input.bool(false, 'Level in Low Risk Zone', group = 'Discount & Premium', tooltip = 'By turning on this feature, demand FVGs are formed in the discount area' +
 'and supply FVGs are formed in the premium area.')
    //Hunt inside or outside the Zone
IssSigM = input.string('Hunt', 'Issuing Signals Method', ['Hunt', 'Sweeps'], group = 'Signal' , tooltip = 'If you want the price to never go out of the zone, put it on the "Hunt" mode,'+
 'and if you want to receive the hunts that are formed outside the range as a signal, put it on the "Sweeps" mode.')
    //The number of reactions allowed in a range
NSA = input.int(3, 'The number of signals allowed from a Zone',minval = 1, tooltip = 'The number of times a signal is issued from a particular FVG.', group = 'Signal')
    //Receiving a signal after several reactions in a range.
SaH = input.bool(false, 'Signal after Hunts/Sweeps', group = 'Signal', tooltip = 'By activating this signal feature, a signal will be issued based on the number of hunts you specify.')
    //The number of reactions to receive a signal
HMH = input.int(2, 'How Many Hunts/Sweeps?',minval = 1, group = 'Signal', tooltip = 'The number of hunts to confirm and issue a signal')
    //Show or hide Setups
SALS = input.bool(false, 'Show All Long Setup' ,group = 'Show or Hide')
SASS = input.bool(false, 'Show All Short Setup',group = 'Show or Hide')
    //Aler
Alert = input.string('On', 'Alert', ['On', 'Off'], 'If you turn on the Alert, you can receive alerts and notifications after setting the "Alert".', group = 'Alert')
AlertName = input.string('ICT Setup 01 Alerts [TradingFinder]', 'Alert Name', group = 'Alert')
Frequncy = input.string('Once Per Bar' , 'Message Frequency' , ['All', 'Once Per Bar' , 'Per Bar Close'], 'The triggering frequency. Possible values are: All'+ 
 ' (all function calls trigger the alert), Once Per Bar (the first function call during the bar triggers the alert), ' +  
 ' Per Bar Close (the function call triggers the alert only when it occurs during the last script iteration of the real-time bar,' +  
 ' when it closes). The default is alert.freq_once_per_bar.)', group = 'Alert')
UTC = input.string('UTC' , 'Show Alert time by Time Zone', group = 'Alert')
MessageBull = input.text_area('Long Signal Position Based on ICT Setup 01 [FVG Hunts]' , 'Long Position Message' , group = 'Alert') 
MessageBear = input.text_area('Short Signal Position Based on ICT Setup 01 [FVG Hunts]', 'Short Position Message',group = 'Alert')





ATR = ta.atr(55)
Body     = (close - open)
FullBody =  math.abs(Body) / (high - low) 



//Bullish Fair Value Gap
var bool     BullFVG        = false
var float    BuFVGDistal    = 0.0
var float    BuFVGProximal  = 0.0
var int      BuFVGPoint    = 0
var line     BuDistalLine   = na
var line     BuProximalLine = na
var linefill BuLineFill     = na
var label BuFVGLabel        = na

//Bearish Fair Value Gap
var bool     BearFVG        = false
var float    BeFVGDistal    = 0.0
var float    BeFVGProximal  = 0.0
var int      BeFVGPoint    = 0
var line     BeDistalLine   = na
var line     BeProximalLine = na
var linefill BeLineFill     = na
var label BeFVGLabel        = na
//Discount and Premium

    //Bull
var float BuPremium      = 0.0 
var float BuDiscount     = 0.0
var float BuEquilibrium  = 0.0
var line BuPremiumLine      = na 
var line BuDiscountLine     = na
var line BuEquilibriumLine  = na
var linefill BuPremFill = na
var linefill BuDisFill  = na
var label BuPremLabel   = na
var label BuDisLabel    = na
var label BuEquiLabel   = na

    //Bear
var float BePremium      = 0.0 
var float BeDiscount     = 0.0
var float BeEquilibrium  = 0.0
var line BePremiumLine      = na 
var line BeDiscountLine     = na
var line BeEquilibriumLine  = na
var linefill BePremFill = na
var linefill BeDisFill  = na
var label BePremLabel   = na
var label BeDisLabel    = na
var label BeEquiLabel   = na


//Signal
    //Bull
var float BuLineSignal = 0.0

    //Bear
var float BeLineSignal = 0.0



//First Levels Detector
if (high - low[2]) > (MATR * ATR) //and FullBody > 0.65 and FullBody[1] > 0.55 and FullBody[2] > 0.5
    if (low > high[2]) and (low[2] < low[1]) and (high[1] < high) and //Body > 0 and Body[1] > 0 and Body[2] > 0 and
     (high + low[2]) / 2 >= high[2]
        BuFVGDistal   := high[2]
        BuFVGProximal := low
        BuFVGPoint    := bar_index
        BuDiscount    := low[2]
        BuPremium     := high
        BuEquilibrium := (high + low[2]) / 2
        BullFVG       := true
    else
        BullFVG       := false
else
    BullFVG           := false


if (high[2] - low) > (MATR * ATR) //and FullBody > 0.65 and FullBody[1] > 0.55 and FullBody[2] > 0.5
    if low[2] > high and (high[2] > high[1]) and (low[1] > low) and //Body < 0 and Body[1] < 0 and Body[2] < 0 and
     (low + high[2]) / 2 <= low[2]
        BeFVGDistal   := low[2]
        BeFVGProximal := high
        BeFVGPoint    := bar_index 
        BeDiscount    := low
        BePremium     := high[2]
        BeEquilibrium := (low + high[2]) / 2
        BearFVG       := true
    else
        BearFVG       := false
else
    BearFVG           := false



//Refine Level and Zone Confirmation

// Refine = input.bool(true, 'Refine FVG')
var float DistalLvLBu    = 0.0
var float ProximalLvLBu  = 0.0

var float DistalLvLBe    = 0.0
var float ProximalLvLBe  = 0.0


//Second Set Level 
    //in Discount & Premium Zone 
if DisANDPre
    if BullFVG
        if BuEquilibrium >= BuFVGProximal
            DistalLvLBu    := BuFVGDistal
            ProximalLvLBu  := BuFVGProximal
        else
            DistalLvLBu    := BuFVGDistal
            ProximalLvLBu  := BuEquilibrium

    if BearFVG
        if BeEquilibrium <= BeFVGProximal
            DistalLvLBe    := BeFVGDistal
            ProximalLvLBe  := BeFVGProximal
        else 
            DistalLvLBe    := BeFVGDistal
            ProximalLvLBe  := BeEquilibrium   
    //in Orginal Zone
else if DisANDPre == false
    if BullFVG
        DistalLvLBu    := BuFVGDistal
        ProximalLvLBu  := BuFVGProximal
    if BearFVG        
        DistalLvLBe    := BeFVGDistal
        ProximalLvLBe  := BeFVGProximal






//Refiner Level
var bool ValidityBuFVG = true
var bool ValidityBeFVG = true

var float Low  = 0.0
var float High = 0.0

var int LSC = 0 //Long Signal Counter
var int SSC = 0 //Short Signal Counter

var bool LongSignal  = false
var bool ShortSignal = false






// if Refine
if ValidityBuFVG //for Bullish FVG
    if Body[1] > 0
        if (IssSigM == 'Sweeps' ? open[1] < DistalLvLBu[1] : low[1] < DistalLvLBu[1]) or bar_index > BuFVGPoint + ValLenFVG or (SaH == false ? LSC > NSA - 1 : false)
            ValidityBuFVG := false            
        else if open[1] < ProximalLvLBu[1] and open[1] > DistalLvLBu[1]
            ProximalLvLBu := open[1]
            // Low := 0.0
            // LSC := 0


    if (Body[1] < 0) or (Body[1] == 0)
        if (IssSigM == 'Sweeps' ? close[1] < DistalLvLBu[1] : low[1] < DistalLvLBu[1]) or bar_index > BuFVGPoint + ValLenFVG or (SaH == false ? LSC > NSA - 1 : false)
            ValidityBuFVG := false            
        else if close[1] < ProximalLvLBu[1] and close[1] > DistalLvLBu[1]
            ProximalLvLBu := close[1]
            // Low := 0.0
            // LSC := 0



if ValidityBeFVG //for Bearish FVG
    if Body[1] > 0
        if (IssSigM == 'Sweeps' ? close[1] > DistalLvLBe[1] : high[1] > DistalLvLBe[1]) or bar_index > BeFVGPoint + ValLenFVG or (SaH == false ? SSC > NSA - 1 : false)
            ValidityBeFVG := false            
        else if close[1] > ProximalLvLBe[1] and close[1] < DistalLvLBe[1]
            ProximalLvLBe := close[1]
            // High := 0.0
            // SSC  := 0

    if (Body[1] < 0) or (Body[1] == 0)
        if (IssSigM == 'Sweeps' ? open[1] > DistalLvLBe[1] : high[1] > DistalLvLBe[1]) or bar_index > BeFVGPoint + ValLenFVG or (SaH == false ? SSC > NSA - 1 : false)
            ValidityBeFVG := false
        else if open[1] > ProximalLvLBe[1] and open[1] < DistalLvLBe[1]
            ProximalLvLBe := open[1]
            // High := 0.0
            // SSC  := 0


if BuFVGPoint[1] != BuFVGPoint
    ValidityBuFVG := true
    Low := 0.0
    LSC  := 0
    LongSignal := false

if BeFVGPoint[1] != BeFVGPoint
    ValidityBeFVG := true
    High := 0.0
    SSC  := 0
    ShortSignal := false


    //Long
if ValidityBuFVG //and BeFVGPoint + 2 < bar_index
    if Low == 0.0 and low[0] < ProximalLvLBu
        Low := low[0]
    if low[0] < Low and  Low > 0.0
        Low := low[0]
        if close >= ProximalLvLBu 
            LSC := LSC + 1 
            if (SaH ? LSC == HMH : true)
                LongSignal := true
        else 
            LongSignal := false
    else 
        LongSignal := false
else
    Low := 0.0
    LSC := 0
    LongSignal := false

    //Short

if ValidityBeFVG //and BuFVGPoint + 2 < bar_index
    if High == 0.0 and high[0] > ProximalLvLBe
        High := high[0]
    if high[0] > High and  High > 0.0 
        High := high[0]
        if close <= ProximalLvLBe  
            SSC  := SSC + 1
            if (SaH ? SSC == HMH : true)
                ShortSignal := true
        else
            ShortSignal := false
    else 
        ShortSignal := false
else 
    High := 0.0
    SSC  := 0
    ShortSignal := false






//Drawing FVG

plotshape(LongSignal, color = #008304, location = location.belowbar, style = shape.triangleup, size = size.small)
plotshape(ShortSignal, color = #d30000, location = location.abovebar, style = shape.triangledown, size = size.small)



if BullFVG
    BuDistalLine   := line.new(BuFVGPoint ,DistalLvLBu ,bar_index , DistalLvLBu, color = #080808ba ,  style = line.style_dashed )
    BuProximalLine := line.new(BuFVGPoint ,ProximalLvLBu ,bar_index , ProximalLvLBu, color = #080808ba ,  style = line.style_dashed )
    BuLineFill     := linefill.new(BuDistalLine, BuProximalLine , color = #4caf4f4d)
    BuFVGLabel     := label.new(BuFVGPoint + 1 , DistalLvLBu, 'FVG', style = label.style_label_down, color = #ffffff00 , textcolor = #000000, size = size.small )
    if DisANDPre
        BuDiscountLine     := line.new(BuFVGPoint + 12, BuDiscount, BuFVGPoint + 20, BuDiscount, color = #00000000)
        BuPremiumLine      := line.new(BuFVGPoint + 12, BuPremium  , BuFVGPoint + 20, BuPremium, color = #00000000)
        BuEquilibriumLine  := line.new(BuFVGPoint + 12, BuEquilibrium, BuFVGPoint + 20, BuEquilibrium, color = #00000000 )
        BuDisFill      := linefill.new(BuDiscountLine, BuEquilibriumLine, #d3eeff6e )
        BuPremFill     := linefill.new(BuPremiumLine , BuEquilibriumLine, #ffa5644b )
        BuDisLabel     := label.new(BuFVGPoint + 16, BuDiscount ,  'Discount', style = label.style_label_center, color = #ffffff00 , textcolor = #000000, size = size.small)
        BuPremLabel    := label.new(BuFVGPoint + 16, BuPremium   ,  'Premium', style = label.style_label_center, color = #ffffff00 , textcolor = #000000, size = size.small)
        BuEquiLabel    := label.new(BuFVGPoint + 16, BuEquilibrium ,  'EQU', style = label.style_label_center, color = #ffffff00 , textcolor = #000000, size = size.small)

if BullFVG == false and ValidityBuFVG and bar_index < BuFVGPoint + ValLenFVG
    line.set_y1(BuProximalLine, ProximalLvLBu)
    line.set_y2(BuProximalLine, ProximalLvLBu)

if bar_index <= BuFVGPoint + ValLenFVG and ValidityBuFVG
    line.set_x2(BuDistalLine, bar_index)
    line.set_x2(BuProximalLine, bar_index)


if BearFVG 
    BeDistalLine   := line.new(BeFVGPoint ,DistalLvLBe ,bar_index , DistalLvLBe, color = #080808ba ,  style = line.style_dashed )
    BeProximalLine := line.new(BeFVGPoint ,ProximalLvLBe ,bar_index , ProximalLvLBe, color = #080808ba ,  style = line.style_dashed )
    BeLineFill     := linefill.new(BeDistalLine, BeProximalLine , color = #ff31314d)
    BeFVGLabel     := label.new(BeFVGPoint + 1 , DistalLvLBe, 'FVG', style = label.style_label_up, color = #ffffff00 , textcolor = #000000, size = size.small )
    if DisANDPre
        BePremiumLine      := line.new(BeFVGPoint + 12, BePremium, BeFVGPoint + 20, BePremium, color = #00000000)
        BeDiscountLine     := line.new(BeFVGPoint + 12, BeDiscount  , BeFVGPoint + 20, BeDiscount, color = #00000000)
        BeEquilibriumLine  := line.new(BeFVGPoint + 12, BeEquilibrium, BeFVGPoint + 20, BeEquilibrium, color = #00000000 )
        BeDisFill      := linefill.new(BeDiscountLine, BeEquilibriumLine, #d3eeff6e )
        BePremFill     := linefill.new(BePremiumLine , BeEquilibriumLine, #ffa5644b )
        BeDisLabel     := label.new(BeFVGPoint + 16, BeDiscount ,  'Discount', style = label.style_label_center, color = #ffffff00 , textcolor = #000000, size = size.small)
        BePremLabel    := label.new(BeFVGPoint + 16, BePremium   ,  'Premium', style = label.style_label_center, color = #ffffff00 , textcolor = #000000, size = size.small)
        BeEquiLabel    := label.new(BeFVGPoint + 16, BeEquilibrium ,  'EQU', style = label.style_label_center, color = #ffffff00 , textcolor = #000000, size = size.small)

if BearFVG == false and ValidityBeFVG and bar_index < BeFVGPoint + ValLenFVG
    line.set_y1(BeProximalLine, ProximalLvLBe)
    line.set_y2(BeProximalLine, ProximalLvLBe)

if bar_index <= BeFVGPoint + ValLenFVG and ValidityBeFVG
    line.set_x2(BeDistalLine, bar_index)
    line.set_x2(BeProximalLine, bar_index)



if BullFVG and BullFVG != false and not SALS 
    line.delete(BuDistalLine[1])   
    line.delete(BuProximalLine[1]) 
    linefill.delete(BuLineFill[1])     
    label.delete(BuFVGLabel[1])    
    line.delete(BuDiscountLine[1])     
    line.delete(BuPremiumLine[1])      
    line.delete(BuEquilibriumLine[1])
    linefill.delete(BuDisFill[1])      
    linefill.delete(BuPremFill[1])     
    label.delete(BuDisLabel[1])    
    label.delete(BuPremLabel[1])    
    label.delete(BuEquiLabel[1])    

if BearFVG and BearFVG != false and not SASS 
    line.delete(BeDistalLine[1])    
    line.delete(BeProximalLine[1]) 
    linefill.delete(BeLineFill[1])     
    label.delete(BeFVGLabel[1])    
    line.delete(BeDiscountLine[1])     
    line.delete(BePremiumLine[1])      
    line.delete(BeEquilibriumLine[1])
    linefill.delete(BeDisFill[1])      
    linefill.delete(BePremFill[1])     
    label.delete(BeDisLabel[1])    
    label.delete(BePremLabel[1])    
    label.delete(BeEquiLabel[1])

//Alert

AlertSender.AlertSender(LongSignal  , Alert, AlertName , 'Setup', '', 'Full' ,'Once Per Bar', 'UTC', 'Off', MessageBull, open, high, low, close,0,0,0,0,0)
AlertSender.AlertSender(ShortSignal , Alert, AlertName , 'Setup', '', 'Full' ,'Once Per Bar', 'UTC', 'Off', MessageBear, open, high, low, close,0,0,0,0,0)

Overview

ICT Setup 01 TFlab identifies liquidity sweeps and hunts within or outside defined zones to generate long and short signals. Signals can be configured to fire after a specified number of hunts or sweeps per zone. The script plots FVG zones, sweep markers and signal arrows directly on the price chart. Users adjust FVG settings, signal thresholds, visibility of all setups and alert preferences including custom messages. Alerts notify on detected long or short positions based on ICT concepts.

Details

Published by

alvinng214 on GitHub

Code credit

TFlab, as written in the script's header

Type

Indicator, Pine Script v5

Draws

On the price chart

Category

SMC / ICT / price action, Support & resistance, Candlestick patterns

Markets

Forex

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
FVG Detector Multiplier Factorfloat1MATR
FVG Validity Periodint15ValLenFVG
Level in Low Risk ZoneboolfalseDisANDPre
Issuing Signals MethodstringHuntIssSigM
The number of signals allowed from a Zoneint3NSA
Signal after Hunts/SweepsboolfalseSaH
How Many Hunts/Sweeps?int2HMH
Show All Long SetupboolfalseSALS
Show All Short SetupboolfalseSASS
AlertstringOnAlert
Alert NamestringICT Setup 01 Alerts [TradingFinder]AlertName
Message FrequencystringOnce Per BarFrequncy
Show all 15 settings
SettingTypeDefaultVariable
Show Alert time by Time ZonestringUTCUTC
Long Position MessagetextLong Signal Position Based on ICT Setup 01 [FVG Hunts]MessageBull
Short Position MessagetextShort Signal Position Based on ICT Setup 01 [FVG Hunts]MessageBear
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

This Pine Script indicator identifies liquidity sweeps and confirms signals using a close-back candle pattern directly on the price chart. It tracks recent swing highs and lows over a customizable lookback period. A bullish signal forms when a prior bar sweeps

Indicator v6 SMC / ICT / price actionSupport & resistance
Updated 2 months ago · MPL-2.0 GitHub repository of Liquidity Sweep + Close-Back Confirmation
46 stars

This overlay indicator draws a set of higher-timeframe candles on the price chart. The user sets the timeframe or lets it select automatically, plus candle count, size, offset, margin, and whether the candles are standard or Heikin Ashi. A table can show the a

Indicator v6 Support & resistanceCandlestick patterns Repaints
Updated 7 weeks ago · None stated GitHub repository of HTF Sweep Model with CISD Table

Fractal Reclaim Strength

by selimgrsoy0-commits
12 stars

The indicator tracks four-bar fractal sweep and reclaim setups on chart timeframes of 15 minutes and above. It calculates Reclaim Strength based on where C2 closes relative to C1's range and plots level lines for the swept C1 extreme and C2 extreme. An on-scre

Indicator v6 SMC / ICT / price actionSupport & resistance
Updated 7 weeks ago · None stated GitHub repository of Fractal Reclaim Strength

ICT HTF Candles (fadi)

by dbruce1990
12 stars

ICT HTF Candles displays higher timeframe candle structures directly on the price chart using customized boxes and lines. It tracks up to six user-defined higher timeframes, plotting historical body, wick, and imbalance zones alongside optional price level tra

Indicator v6 SMC / ICT / price actionCandlestick patterns
Updated 1 year ago · None stated GitHub repository of ICT HTF Candles (fadi)

This overlay indicator detects tweezer tops and bottoms and kangaroo-tail pin bars, then draws supply and demand zones from those patterns. It scores each zone, decays freshness, merges overlapping zones, and can invalidate a zone after a close-through or afte

Indicator v6 Candlestick patternsSupport & resistance
Updated yesterday · MIT GitHub repository of Tweezer & Kangaroo Zones [WavesUnchained]

Assistant

by eddiebelaval
7 stars

Assistant is an overlay indicator that marks candles with small or missing upper and lower wicks, using a threshold relative to body size. It plots three-candle and five-candle swing fractals as triangles two bars back, and fires alerts when a bullish or beari

Indicator v6 Candlestick patternsSupport & resistance
Updated 3 months ago · None stated GitHub repository of Assistant

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