Indicator · Pine Script v5 · On the chart

ICT Liquidity Sweep Pattern Scanner

by ArunKBhaskar

This overlay indicator scans a pasted list of symbols for ICT liquidity sweep patterns using prior swing sweeps.

View on GitHub

GitHub stars575on the repository
Pine versionv5runs as is
Lines of code667
Settings26inputs
LicenceMPL-2.0
Last update1 year ago30 Mar 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

667 lines of Pine Script v5 from ICT Liquidity Sweep Pattern Scanner/Scanner - ICT Liquidity Sweep Pattern Scanner.txt, published under MPL-2.0. Keep the author's credit and licence lines when you reuse it.

Scanner - ICT Liquidity Sweep Pattern Scanner.txt
// This Pine Script™ code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © Arun_K_Bhaskar

//@version=5
indicator(title='ICT Liquidity Sweep Pattern Scanner', shorttitle='ICT LSP Scan', overlay=true, max_bars_back=500, max_lines_count=500, max_boxes_count=500)

//_____________________________ Menu Screener Start

g_scrtb = '█████████████████ Scanner █████████████████'

string i_scr_choose = input.string(defval='Prev 2 Swing Sweep', title='Screening Method', options=['Prev 1 Swing Sweep', 'Prev 2 Swing Sweep', 'Prev 3 Swing Sweep'], group=g_scrtb)

tt_is = "• Reads only up to first 40 symbols." +
     "\n• Total characters cannot exceed 4096." +
     "\n• Eg: EXCHANGE:SYMBOL_A,EXCHANGE:SYMBOL_B"

string i_symbols = input.text_area(
 defval="NSE:ABCAPITAL,NSE:BIOCON,NSE:BLS,NSE:BOMDYEING,NSE:CAPACITE,NSE:CESC,NSE:CHAMBLFERT,NSE:DCBBANK,NSE:ENGINERSIN,NSE:GIPCL,NSE:GMDCLTD,NSE:GSFC,NSE:HINDCOPPER,NSE:HINDOILEXP,NSE:INDIACEM,NSE:IOC,NSE:IRCON,NSE:IRFC,NSE:LTFOODS,NSE:MANAPPURAM,NSE:M_MFIN,NSE:NATIONALUM,NSE:NBCC,NSE:NFL,NSE:NLCINDIA,NSE:NMDC,NSE:PNB,NSE:PRAKASH,NSE:PTC,NSE:RAILTEL,NSE:RAIN,NSE:RBLBANK,NSE:RCF,NSE:RELINFRA,NSE:SAIL,NSE:SARDAEN,NSE:SJVN,NSE:TATASTEEL,NSE:TIMETECHNO,NSE:VEDL", 
 title="Paste Symbols", tooltip=tt_is, group=g_scrtb)

bool i_scr_show_table  = input.bool(defval=true, title='Display Table', group=g_scrtb)
bool i_scr_show_long  = input.bool(defval=true, title='Long Signals', inline='tb_2', group=g_scrtb)
bool i_scr_show_short  = input.bool(defval=true, title='Short Signals', inline='tb_2', group=g_scrtb)

int i_scr_tbl_disp_rows = input.int(defval=12, title='Display Rows', minval=0, maxval=100, group=g_scrtb)
string i_scr_tbl_position = input.string(defval=position.bottom_left, title='Table Position', options=[position.top_left, position.top_center, position.top_right, position.middle_left, position.middle_center, position.middle_right, position.bottom_left, position.bottom_center, position.bottom_right], group=g_scrtb)
string i_scr_tbl_text_size = input.string(defval=size.small, title='Table Size', options=[size.auto, size.tiny, size.small, size.normal, size.large, size.huge], group=g_scrtb)

//_____________________________ Menu Screener End

//_____________________________ Menu Zig Zag Start 

g_zz = '██████████████████ Zig Zag ██████████████████'

bool i_zz_display = input.bool(defval=true, title='Display Zig Zag', group=g_zz)
int i_zz_period = input.int(defval=4, title='Zig Zag Length', minval=2, group=g_zz)
string i_zz_source = input.string(defval='High/Low', title='Source', options=['High/Low', 'Open/Close'], group=g_zz)
color i_zz_bull_color = input.color(defval=#1E53E5, title='Color Up', group=g_zz)
color i_zz_bear_color = input.color(defval=#1E53E5, title='Color Down', group=g_zz)
string i_zz_ln_style = input.string(defval=line.style_solid, title="Line Style", options=[line.style_solid, line.style_dashed, line.style_dotted], group=g_zz)

//_____________________________ Menu Zig Zag End 

//_____________________________ Menu Table Start

g_dtb = '█████████████████ Data Table █████████████████'
bool i_tbl_data_show  = input.bool(defval=true, title='Display Table', group=g_dtb)
string i_tbl_data_pos = input.string(defval=position.bottom_right, title='Position', options=[position.top_left, position.top_center, position.top_right, position.middle_left, position.middle_center, position.middle_right, position.bottom_left, position.bottom_center, position.bottom_right], group=g_dtb)
string i_tbl_data_txt_size = input.string(defval=size.normal, title='Size', options=[size.auto, size.tiny, size.small, size.normal, size.large, size.huge], group=g_dtb)

//_____________________________ Menu Table End

//_____________________________ Chart Settings Start

g_ch = '███████████████ Chart Settings ███████████████'
color i_pos_dark_color = input.color(defval=#03110F, title='Positive Dark', group=g_ch)
color i_pos_color = input.color(defval=#26A69A, title='Positive Mid', group=g_ch)
color i_pos_light_color = input.color(defval=#ACE5DC, title='Positive Light', group=g_ch)
color i_neg_light_color = input.color(defval=#FCCBCD, title='Negative Light', group=g_ch)
color i_neg_color = input.color(defval=#FF5252, title='Negative Mid', group=g_ch)
color i_neg_dark_color = input.color(defval=#180809, title='Negative Dark', group=g_ch)
//color i_indicator_color = input.color(defval=#2962FF, title='Indicator', group=g_ch)
//color i_signal_color = input.color(defval=#FF6D00, title='Signal', group=g_ch)
color i_neu_color = input.color(defval=#D1D4DC, title='Neutral Light', group=g_ch)
color i_neu_mid_color = input.color(defval=#2A2E39, title='Neutral Mid', group=g_ch)
color i_neu_dark_color = input.color(defval=#141516, title='Neutral Dark', group=g_ch)

//_____________________________ Chart Settings End

//_____________________________ Cumulative Percentage Change Start

// Function to calculate Daily Cumulative Percentage Change of Close Price
cumulative_percentage_change() =>
    var float _cum_pct_change = na
    _is_new_day = ta.change(time('D')) != 0 ? 1 : 0
    _daily_pct_change = na(close[1]) ? 0 : (close - close[1]) / close[1] * 100
    _cum_pct_change := _is_new_day ? _daily_pct_change : (na(_cum_pct_change) ? _daily_pct_change : (_cum_pct_change + _daily_pct_change))
    _cum_pct_change

// Calculate current cumulative percentage change
cum_pchg = cumulative_percentage_change()

//_____________________________ Cumulative Percentage Change End

//_____________________________ Cumulative Volume Percentage Change Start

// Function to calculate Daily Cumulative Volume
cumulative_volume() =>
    var float _cum_vol = na
    _is_new_day = ta.change(time('D')) != 0 ? 1 : 0
    _cum_vol := _is_new_day ? volume : (na(_cum_vol) ? volume : (_cum_vol + volume))
    _cum_vol

// Calculate current and previous day cumulative volumes
var float current_cum_vol = na
var float prev_cum_vol = na

if ta.change(time('D')) != 0
    prev_cum_vol := current_cum_vol
    current_cum_vol := volume
else
    current_cum_vol += volume

// Calculate Cumulative Volume Percentage Change
cum_vol_pchg = (current_cum_vol - nz(prev_cum_vol, current_cum_vol)) / nz(prev_cum_vol, current_cum_vol) * 100

//_____________________________ Cumulative Volume Percentage Change End

//_____________________________ Zig Zag Start 

// Acknowledgement & Reference
// Trader: 'RozaniGhani-RG'
// Indicator Title: 'Zig Zag Ratio Simplified'
// Indicator Link: 'https://www.tradingview.com/script/CIk186OY-Zig-Zag-Ratio-Simplified/'

//_____________________________ Get Source

float _high = i_zz_source == 'Open/Close' ? math.max(open, close) : high
float _low = i_zz_source == 'Open/Close' ? math.min(open, close) : low

//============================== 1.  Variables

//_____________________________ 1.1 Highest / Lowest
float ph = ta.highestbars(_high, i_zz_period) == 0 ? _high : na
float pl = ta.lowestbars(_low, i_zz_period) == 0 ? _low  : na

//_____________________________ 1.2 Dir
var int dir = 0, dir := pl and na(ph) ? -1 : ph and na(pl) ? 1 : dir

//_____________________________ 1.4 Array
var max_array_size = 14, var zigzag = array.new_float(0), oldzigzag = array.copy(zigzag)

//_____________________________ 1.5 Others
var line line_zz = na

//============================== 3.  Custom Functions

add_to_zigzag(float[] pointer, float value, int bindex) =>
    array.unshift(pointer, bindex)
    array.unshift(pointer, value)
    if array.size(pointer) > max_array_size
        array.pop(pointer)
        array.pop(pointer)
    
update_zigzag(float[] pointer, float value, int bindex, int dir) =>
    if array.size(pointer) == 0
        add_to_zigzag(pointer, value, bindex)
    else
        if dir == 1 and value > array.get(pointer, 0) or dir == -1 and value < array.get(pointer, 0)
            array.set(pointer, 0, value)
            array.set(pointer, 1, bindex)
        0.

//============================== 4.  Calculations

dirchanged = ta.change(dir)

if ph or pl
    if dirchanged
        add_to_zigzag(zigzag, dir == 1 ? ph : pl, bar_index)
    else
        update_zigzag(zigzag, dir == 1 ? ph : pl, bar_index, dir)

//============================== 5.  Constructs

if array.size(zigzag) >= 6
    if array.get(zigzag, 0) != array.get(oldzigzag, 0) or array.get(zigzag, 1) != array.get(oldzigzag, 1)
        if array.get(zigzag, 2) == array.get(oldzigzag, 2) and array.get(zigzag, 3) == array.get(oldzigzag, 3)
            line.delete(line_zz)
        if i_zz_display
            line_zz := line.new(x1 = math.round(array.get(zigzag, 1)), y1 = array.get(zigzag, 0), x2 = math.round(array.get(zigzag, 3)), y2 = array.get(zigzag, 2), color = dir == 1 ? i_zz_bull_color : i_zz_bear_color, width=1)

//_____________________________ Get Swing Price & Bar Index

//zz_0 = array.size(zigzag) > 15 ? array.get(zigzag, array.size(zigzag) - 16) : na
//bi_0 = array.size(zigzag) > 14 ? array.get(zigzag, array.size(zigzag) - 15) : na
zz_1 = array.size(zigzag) > 13 ? array.get(zigzag, array.size(zigzag) - 14) : na
//bi_1 = array.size(zigzag) > 12 ? array.get(zigzag, array.size(zigzag) - 13) : na
zz_2 = array.size(zigzag) > 11 ? array.get(zigzag, array.size(zigzag) - 12) : na
//bi_2 = array.size(zigzag) > 10 ? array.get(zigzag, array.size(zigzag) - 11) : na
zz_3 = array.size(zigzag) > 9 ? array.get(zigzag, array.size(zigzag) - 10) : na
bi_3 = array.size(zigzag) > 8 ? array.get(zigzag, array.size(zigzag) - 9) : na
zz_4 = array.size(zigzag) > 7 ? array.get(zigzag, array.size(zigzag) - 8) : na
//bi_4 = array.size(zigzag) > 6 ? array.get(zigzag, array.size(zigzag) - 7) : na
zz_5 = array.size(zigzag) > 5 ? array.get(zigzag, array.size(zigzag) - 6) : na
bi_5 = array.size(zigzag) > 4 ? array.get(zigzag, array.size(zigzag) - 5) : na
zz_6 = array.size(zigzag) > 3 ? array.get(zigzag, array.size(zigzag) - 4) : na
//bi_6 = array.size(zigzag) > 2 ? array.get(zigzag, array.size(zigzag) - 3) : na
zz_7 = array.size(zigzag) > 1 ? array.get(zigzag, array.size(zigzag) - 2) : na
bi_7 = array.size(zigzag) > 0 ? array.get(zigzag, array.size(zigzag) - 1) : na

// Create a single label for the last five zigzag values and their corresponding bar index
//label_text = str.tostring(zz_0) + "\n" + str.tostring(bi_0) + "\n" + str.tostring(zz_1) + "\n" + str.tostring(bi_1) + "\n" + str.tostring(zz_2) + 
// "\n" + str.tostring(bi_2) + "\n" + str.tostring(zz_3) + "\n" + str.tostring(bi_3) + "\n" + str.tostring(zz_4) + "\n" + str.tostring(bi_4)
//if barstate.islast
//    label.new(x = bar_index, y = high, text = label_text, color=color.white)

//_____________________________ Zig Zag End

//_____________________________ Signals Start

// Short Condition
short_condition_1 = 
 zz_2 < zz_3 and
 zz_2 < zz_4 and
 zz_2 < zz_6 and
 zz_2 < zz_7 and

 zz_3 < zz_5 and
 zz_3 > zz_4 and
 zz_3 > zz_2 and

 zz_4 < zz_3 and
 zz_4 < zz_5 and
 zz_4 < zz_6 and
 zz_4 < zz_7 and

 zz_5 > zz_3 and
 zz_5 > zz_4 and
 zz_5 > zz_6 and
 zz_5 < zz_7 and

 zz_6 < zz_5 and
 zz_6 < zz_7 and
 zz_6 > zz_4 and

 zz_7 > zz_2 and
 zz_7 > zz_3 and
 zz_7 > zz_4 and
 zz_7 > zz_5 and
 zz_7 > zz_6 and

 ta.crossover(zz_1, zz_3) and

 barstate.isconfirmed

short_condition_2 = 
 zz_2 < zz_3 and
 zz_2 < zz_4 and
 zz_2 < zz_6 and
 zz_2 < zz_7 and

 zz_3 < zz_5 and
 zz_3 > zz_4 and
 zz_3 > zz_2 and

 zz_4 < zz_3 and
 zz_4 < zz_5 and
 zz_4 < zz_6 and
 zz_4 < zz_7 and

 zz_5 > zz_3 and
 zz_5 > zz_4 and
 zz_5 > zz_6 and
 zz_5 < zz_7 and

 zz_6 < zz_5 and
 zz_6 < zz_7 and
 zz_6 > zz_4 and

 zz_7 > zz_2 and
 zz_7 > zz_3 and
 zz_7 > zz_4 and
 zz_7 > zz_5 and
 zz_7 > zz_6 and

 ta.crossover(zz_1, zz_5) and

 barstate.isconfirmed

short_condition_3 = 
 zz_2 < zz_3 and
 zz_2 < zz_4 and
 zz_2 < zz_6 and
 zz_2 < zz_7 and

 zz_3 < zz_5 and
 zz_3 > zz_4 and
 zz_3 > zz_2 and

 zz_4 < zz_3 and
 zz_4 < zz_5 and
 zz_4 < zz_6 and
 zz_4 < zz_7 and

 zz_5 > zz_3 and
 zz_5 > zz_4 and
 zz_5 > zz_6 and
 zz_5 < zz_7 and

 zz_6 < zz_5 and
 zz_6 < zz_7 and
 zz_6 > zz_4 and

 zz_7 > zz_2 and
 zz_7 > zz_3 and
 zz_7 > zz_4 and
 zz_7 > zz_5 and
 zz_7 > zz_6 and

 ta.crossover(zz_1, zz_7) and

 barstate.isconfirmed

// Long Condition
long_condition_1 = 
 zz_2 < zz_3 and
 zz_2 < zz_4 and
 zz_2 < zz_6 and
 zz_2 < zz_7 and

 zz_3 < zz_5 and
 zz_3 > zz_4 and
 zz_3 > zz_2 and

 zz_4 < zz_3 and
 zz_4 < zz_5 and
 zz_4 < zz_6 and
 zz_4 < zz_7 and

 zz_5 > zz_3 and
 zz_5 > zz_4 and
 zz_5 > zz_6 and
 zz_5 < zz_7 and

 zz_6 < zz_5 and
 zz_6 < zz_7 and
 zz_6 > zz_4 and

 zz_7 > zz_2 and
 zz_7 > zz_3 and
 zz_7 > zz_4 and
 zz_7 > zz_5 and
 zz_7 > zz_6 and

 ta.crossunder(zz_1, zz_3) and

 barstate.isconfirmed

long_condition_2 = 
 zz_2 > zz_3 and
 zz_2 > zz_4 and
 zz_2 > zz_6 and
 zz_2 > zz_7 and

 zz_3 > zz_5 and
 zz_3 < zz_4 and
 zz_3 < zz_2 and

 zz_4 > zz_3 and
 zz_4 > zz_5 and
 zz_4 > zz_6 and
 zz_4 > zz_7 and

 zz_5 < zz_3 and
 zz_5 < zz_4 and
 zz_5 < zz_6 and
 zz_5 > zz_7 and

 zz_6 > zz_5 and
 zz_6 > zz_7 and
 zz_6 < zz_4 and

 zz_7 < zz_2 and
 zz_7 < zz_3 and
 zz_7 < zz_4 and
 zz_7 < zz_5 and
 zz_7 < zz_6 and

 ta.crossunder(zz_1, zz_5) and

 barstate.isconfirmed

long_condition_3 = 
 zz_2 > zz_3 and
 zz_2 > zz_4 and
 zz_2 > zz_6 and
 zz_2 > zz_7 and

 zz_3 > zz_5 and
 zz_3 < zz_4 and
 zz_3 < zz_2 and

 zz_4 > zz_3 and
 zz_4 > zz_5 and
 zz_4 > zz_6 and
 zz_4 > zz_7 and

 zz_5 < zz_3 and
 zz_5 < zz_4 and
 zz_5 < zz_6 and
 zz_5 > zz_7 and

 zz_6 > zz_5 and
 zz_6 > zz_7 and
 zz_6 < zz_4 and

 zz_7 < zz_2 and
 zz_7 < zz_3 and
 zz_7 < zz_4 and
 zz_7 < zz_5 and
 zz_7 < zz_6 and

 ta.crossunder(zz_1, zz_7) and

 barstate.isconfirmed

// Plot Signals
plotshape(series=i_scr_show_short and i_scr_choose == 'Prev 1 Swing Sweep' ? short_condition_1 : na, title='Prev 1 Bearish Sweep', style=shape.triangledown, location=location.abovebar, color=i_neg_light_color, size=size.tiny)
plotshape(series=i_scr_show_long and i_scr_choose == 'Prev 1 Swing Sweep' ? long_condition_1 : na, title='Prev 1 Bullish Sweep', style=shape.triangleup, location=location.belowbar, color=i_pos_light_color, size=size.tiny)
barcolor(color=i_scr_show_short and i_scr_choose == 'Prev 1 Swing Sweep' and short_condition_1 ? i_neg_light_color : i_scr_show_long and i_scr_choose == 'Prev 1 Swing Sweep' and long_condition_1 ? i_pos_light_color : na, title='Prev 1 Candle')

plotshape(series=i_scr_show_short and i_scr_choose == 'Prev 2 Swing Sweep' ? short_condition_2 : na, title='Prev 2 Bearish Sweep', style=shape.triangledown, location=location.abovebar, color=i_neg_light_color, size=size.tiny)
plotshape(series=i_scr_show_long and i_scr_choose == 'Prev 2 Swing Sweep' ? long_condition_2 : na, title='Prev 2 Bullish Sweep', style=shape.triangleup, location=location.belowbar, color=i_pos_light_color, size=size.tiny)
barcolor(color=i_scr_show_short and i_scr_choose == 'Prev 2 Swing Sweep' and short_condition_2 ? i_neg_light_color : i_scr_show_long and i_scr_choose == 'Prev 2 Swing Sweep' and long_condition_2 ? i_pos_light_color : na, title='Prev 2 Candle')

plotshape(series=i_scr_show_short and i_scr_choose == 'Prev 3 Swing Sweep' ? short_condition_3 : na, title='Prev 3 Bearish Sweep', style=shape.triangledown, location=location.abovebar, color=i_neg_light_color, size=size.tiny)
plotshape(series=i_scr_show_long and i_scr_choose == 'Prev 3 Swing Sweep' ? long_condition_3 : na, title='Prev 3 Bullish Sweep', style=shape.triangleup, location=location.belowbar, color=i_pos_light_color, size=size.tiny)
barcolor(color=i_scr_show_short and i_scr_choose == 'Prev 3 Swing Sweep' and short_condition_3 ? i_neg_light_color : i_scr_show_long and i_scr_choose == 'Prev 3 Swing Sweep' and long_condition_3 ? i_pos_light_color : na, title='Prev 3 Candle')

//
var line_array = array.new_line()
// 1
if i_scr_show_short and i_scr_choose == 'Prev 1 Swing Sweep' and short_condition_1
    ph_line = line.new(x1=int(bi_3), y1=zz_3, x2=bar_index, y2=zz_3, color=i_neg_color, style=i_zz_ln_style)
    array.push(line_array, ph_line)

if i_scr_show_long and i_scr_choose == 'Prev 1 Swing Sweep' and long_condition_1
    pl_line = line.new(x1=int(bi_3), y1=zz_3, x2=bar_index, y2=zz_3, color=i_pos_color, style=i_zz_ln_style)
    array.push(line_array, pl_line)

// 2
if i_scr_show_short and i_scr_choose == 'Prev 2 Swing Sweep' and short_condition_2
    ph_line = line.new(x1=int(bi_5), y1=zz_5, x2=bar_index, y2=zz_5, color=i_neg_color, style=i_zz_ln_style)
    array.push(line_array, ph_line)

if i_scr_show_long and i_scr_choose == 'Prev 2 Swing Sweep' and long_condition_2
    pl_line = line.new(x1=int(bi_5), y1=zz_5, x2=bar_index, y2=zz_5, color=i_pos_color, style=i_zz_ln_style)
    array.push(line_array, pl_line)

// 3
if i_scr_show_short and i_scr_choose == 'Prev 3 Swing Sweep' and short_condition_3
    ph_line = line.new(x1=int(bi_7), y1=zz_7, x2=bar_index, y2=zz_7, color=i_neg_color, style=i_zz_ln_style)
    array.push(line_array, ph_line)

if i_scr_show_long and i_scr_choose == 'Prev 3 Swing Sweep' and long_condition_3
    pl_line = line.new(x1=int(bi_7), y1=zz_7, x2=bar_index, y2=zz_7, color=i_pos_color, style=i_zz_ln_style)
    array.push(line_array, pl_line)

//_____________________________ Signals End

//_____________________________ Data Table Start

// To String
day_pchg_str = str.tostring(cum_pchg,"#.##") + ' %'
volume_pchg_str = str.tostring(cum_vol_pchg,"#.##") + ' %'
day_volume_str = str.tostring(current_cum_vol/100000,"#.##") + ' L'
prev_day_volume_str = str.tostring(prev_cum_vol/100000,"#.##") + ' L'

// Color
bgcolor_1 = i_neu_dark_color
bgcolor_2 = i_neu_mid_color

pchg_col = cum_pchg > 0 ? i_pos_color : i_neg_color
vol_pchg_col = cum_vol_pchg > 0 ? i_pos_color : i_neg_color
prev_vol_pchg_col = prev_cum_vol < current_cum_vol ? i_neg_color : i_pos_color

// Plot Table
var table tbl_data = table.new(position=i_tbl_data_pos, columns=2, rows=4, border_width=1, force_overlay=true)

if barstate.islast and i_tbl_data_show
    table.cell(table_id=tbl_data, column=0, row=0, text="%Chg", text_color=i_neu_color, text_halign=text.align_left, bgcolor=bgcolor_1, text_size=i_tbl_data_txt_size)
    table.cell(table_id=tbl_data, column=1, row=0, text=day_pchg_str, text_color=pchg_col, text_halign=text.align_right, bgcolor=bgcolor_1, text_size=i_tbl_data_txt_size)

    table.cell(table_id=tbl_data, column=0, row=1, text="Vol %Chg", text_color=i_neu_color, text_halign=text.align_left, bgcolor=bgcolor_2, text_size=i_tbl_data_txt_size)
    table.cell(table_id=tbl_data, column=1, row=1, text=volume_pchg_str, text_color=vol_pchg_col, text_halign=text.align_right, bgcolor=bgcolor_2, text_size=i_tbl_data_txt_size)

    table.cell(table_id=tbl_data, column=0, row=2, text="Vol", text_color=i_neu_color, text_halign=text.align_left, bgcolor=bgcolor_1, text_size=i_tbl_data_txt_size)
    table.cell(table_id=tbl_data, column=1, row=2, text=day_volume_str, text_color=vol_pchg_col, text_halign=text.align_right, bgcolor=bgcolor_1, text_size=i_tbl_data_txt_size)

    table.cell(table_id=tbl_data, column=0, row=3, text="PD Vol", text_color=i_neu_color, text_halign=text.align_left, bgcolor=bgcolor_2, text_size=i_tbl_data_txt_size)
    table.cell(table_id=tbl_data, column=1, row=3, text=prev_day_volume_str, text_color=prev_vol_pchg_col, text_halign=text.align_right, bgcolor=bgcolor_2, text_size=i_tbl_data_txt_size)

//_____________________________ Data Table End

//_____________________________ Get Symbols for Screener Start

// Acknowledgement & Reference
// Trader: 'allanster'
// Indicator Title: 'How To Input CSV List Of Symbol Data Used For Screener'
// Indicator Link: 'https://www.tradingview.com/script/KfqHqHUH-How-To-Input-CSV-List-Of-Symbol-Data-Used-For-Screener/'

feed(back) =>                                             // extract tickerid and decrement list of ticker IDs
    loop  = back                                          // declare string variable to hold content list
    getT  = string(na)                                    // declare string variable to hold tickerid
    if str.length(loop) == 0                              // if list is empty
        getT := string(na)                                // assign na to tickerid variable
        loop := string(na)                                // assign na to list of ticker Ids variable
    else                                                  // else extract first tickerid
        getP  = nz(str.pos(loop, ','), str.length(loop))  // get position of first comma or last character
        getT := str.substring(loop, 0, getP)              // get tickerid in first position of list
        loop := str.replace(loop, getT + ',', '')         // clear tickerid + delimiter character from list
    [getT, loop]                                          // return tickerid in first position & truncated list

[tid_01, out_01] = feed(i_symbols), [tid_02, out_02] = feed(out_01), [tid_03, out_03] = feed(out_02), [tid_04, out_04] = feed(out_03),
[tid_05, out_05] = feed(out_04), [tid_06, out_06] = feed(out_05), [tid_07, out_07] = feed(out_06), [tid_08, out_08] = feed(out_07),
[tid_09, out_09] = feed(out_08), [tid_10, out_10] = feed(out_09), [tid_11, out_11] = feed(out_10), [tid_12, out_12] = feed(out_11),
[tid_13, out_13] = feed(out_12), [tid_14, out_14] = feed(out_13), [tid_15, out_15] = feed(out_14), [tid_16, out_16] = feed(out_15),
[tid_17, out_17] = feed(out_16), [tid_18, out_18] = feed(out_17), [tid_19, out_19] = feed(out_18), [tid_20, out_20] = feed(out_19),
[tid_21, out_21] = feed(out_20), [tid_22, out_22] = feed(out_21), [tid_23, out_23] = feed(out_22), [tid_24, out_24] = feed(out_23),
[tid_25, out_25] = feed(out_24), [tid_26, out_26] = feed(out_25), [tid_27, out_27] = feed(out_26), [tid_28, out_28] = feed(out_27),
[tid_29, out_29] = feed(out_28), [tid_30, out_30] = feed(out_29), [tid_31, out_31] = feed(out_30), [tid_32, out_32] = feed(out_31),
[tid_33, out_33] = feed(out_32), [tid_34, out_34] = feed(out_33), [tid_35, out_35] = feed(out_34), [tid_36, out_36] = feed(out_35),
[tid_37, out_37] = feed(out_36), [tid_38, out_38] = feed(out_37), [tid_39, out_39] = feed(out_38), [tid_40, out_40] = feed(out_39)

//_____________________________ Get Symbols for Screener End

//_____________________________ Screener Start

// Acknowledgement & Reference
// Trader: 'MUQWISHI'
// Indicator Title: 'Candlestick Patterns Screener [By MUQWISHI]'
// Indicator Link: 'https://www.tradingview.com/script/xiWQuGOq-Candlestick-Patterns-Screener-By-MUQWISHI/'

// Choose Screening Method
short_cond = 
 i_scr_choose == 'Prev 1 Swing Sweep' ? short_condition_1 :
 i_scr_choose == 'Prev 2 Swing Sweep' ? short_condition_2 : short_condition_3

long_cond =
 i_scr_choose == 'Prev 1 Swing Sweep' ? long_condition_1 :
 i_scr_choose == 'Prev 2 Swing Sweep' ? long_condition_2 : long_condition_3

// Function for Screener Indicator Calculation
indicator_calculation() =>
    // Initialize variables
    price = float(na)
    _time = int(na)
    _cum_pchg = float(na)
    _cum_vol_pchg = float(na)
    signal = int(na) 

    if barstate.isconfirmed
        // Check for Short Momentum Candle and conditions (Modify here to customize indicators)
        if i_scr_show_long and long_cond
            signal := 1

        // Check for Long Momentum Candle and conditions (Modify here to customize indicators)
        else if i_scr_show_short and short_cond
            signal := -1

        // Update price and time if signal is not null
        if not na(signal)
            price := math.round_to_mintick(close)
            _time := time
            _cum_pchg := cum_pchg
            _cum_vol_pchg := cum_vol_pchg

    [_time, price, _cum_pchg, _cum_vol_pchg, signal]

// Function to format time
format_time(x) =>
    timezone = syminfo.timezone
    timeframe.isintraday ? str.format_time(x, "HH:mm  dd-MM-yyyy", timezone) : str.format_time(x, "dd-MM-yyyy", timezone)

// Function to extract symbol name
symbol(s) => 
    array.get(str.split(s, ":"), 1)

// Matrix setup
var matrix = matrix.new<string>(0, 6, na)

// Function to add rows to the matrix
mtxFun(symbol, _time, price, _cum_pchg, _cum_vol_pchg, signal) =>
    matrix.add_row(matrix, 0, array.from(symbol, _time, price, _cum_pchg, _cum_vol_pchg, signal))

// Screener function to collect data
screener(s) =>
    sym = ticker.modify(s, syminfo.session)
    [_time, price, _cum_pchg, _cum_vol_pchg, signal] = request.security(sym, timeframe.period, indicator_calculation())

    // Check if the signal is not na and the time matches
    if not na(signal) and _time == time
        symbolName = symbol(s)
        formattedTime = format_time(_time)
        strPrice = str.tostring(price)
        str_cum_pchg = str.tostring(_cum_pchg, '#.##')
        str_cum_vol_pchg = str.tostring(_cum_vol_pchg, '#.##')
        strSignal = str.tostring(signal)
        
        // Add data to the matrix
        mtxFun(symbolName, formattedTime, strPrice, str_cum_pchg, str_cum_vol_pchg, strSignal)

// Call Screener function for multiple symbols
screener(tid_01), screener(tid_02), screener(tid_03), screener(tid_04), screener(tid_05), screener(tid_06), screener(tid_07),
screener(tid_08), screener(tid_09), screener(tid_10), screener(tid_11), screener(tid_12), screener(tid_13), screener(tid_14),
screener(tid_15), screener(tid_16), screener(tid_17), screener(tid_18), screener(tid_19), screener(tid_20), screener(tid_21),
screener(tid_22), screener(tid_23), screener(tid_24), screener(tid_25), screener(tid_26), screener(tid_27), screener(tid_28),
screener(tid_29), screener(tid_30), screener(tid_31), screener(tid_32), screener(tid_33), screener(tid_34), screener(tid_35),
screener(tid_36), screener(tid_37), screener(tid_38), screener(tid_39), screener(tid_40)

// Trim excess rows in the matrix
if matrix.rows(matrix) > i_scr_tbl_disp_rows
    while matrix.rows(matrix) > i_scr_tbl_disp_rows
        matrix.remove_row(matrix, matrix.rows(matrix)-1)

// Plot Table
// Create table with specified properties
var table scr_tbl = table.new(position=i_scr_tbl_position, columns=5, rows=102, border_width=1)

// Function to populate cells in the table
scr_cell_title(col, row, txt) => 
    table.cell(scr_tbl, col, row, text = txt, text_color = i_neu_color, text_halign=text.align_center, bgcolor=i_neu_dark_color, text_size=i_scr_tbl_text_size)

scr_cell(col, row, txt, _text_color, _bgcolor) => 
    table.cell(scr_tbl, col, row, text = txt, text_color = _text_color, text_halign=text.align_left, bgcolor=_bgcolor, text_size=i_scr_tbl_text_size)

// Check if it's the last bar
if barstate.islast and i_scr_show_table
    // Clear existing data in the table
    table.clear(scr_tbl, 0, 0, 2, 101)

    scr_cell_title(0, 0, i_scr_choose)
    table.merge_cells(table_id=scr_tbl, start_column=0, start_row=0, end_column=4, end_row=0)
    scr_cell_title(0, 1, "Symbol")
    scr_cell_title(1, 1, "Time")
    scr_cell_title(2, 1, "Price")
    scr_cell_title(3, 1, "%Chg")
    scr_cell_title(4, 1, "V %Chg")

    j = 4
    // Populate table with matrix data
    if matrix.rows(matrix) > 0
        for i = 0 to matrix.rows(matrix) - 1
            // Determine color based on the signal

            _textcolor = 
             matrix.get(matrix, i, 5) ==  "1" ? i_pos_color : 
             matrix.get(matrix, i, 5) == "-1" ? i_neg_color : i_neu_color

            _bg_color = 
             matrix.get(matrix, i, 5) ==  "1" ? i_pos_dark_color :
             matrix.get(matrix, i, 5) == "-1" ? i_neg_dark_color : i_neu_color

            // Populate cells in the table
            scr_cell(0, j, matrix.get(matrix, i, 0), _textcolor, _bg_color)
            scr_cell(1, j, matrix.get(matrix, i, 1), _textcolor, _bg_color)
            scr_cell(2, j, matrix.get(matrix, i, 2), _textcolor, _bg_color)
            scr_cell(3, j, matrix.get(matrix, i, 3), _textcolor, _bg_color)
            scr_cell(4, j, matrix.get(matrix, i, 4), _textcolor, _bg_color)

            j += 1

//_____________________________ Screener End

//_____________________________ Code End

// Readme First:

// ICT Liquidity Sweep Pattern Scanner

// Logic
//   - This generally identifies bullish or bearish liquidity sweeps of previous 1st, 2nd, or 3rd swings.

// Notes
//   - Use higher timeframes for stock selection and trade in lower timeframes.
//   - The scanner may also generate incorrect signals.

Overview

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, and text size. A zigzag drawn from highs and lows or opens and closes marks swings on the price chart, with length, colors, and line style settings. A second data table can be shown and repositioned. Input is limited to the first forty symbols.

Details

Published by

ArunKBhaskar on GitHub

Type

Indicator, Pine Script v5

Draws

On the price chart

Category

SMC / ICT / price action, Screeners & dashboards, Support & resistance

Markets

Stocks

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

pinescripttradingview

Settings

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

SettingTypeDefaultVariable
Screening MethodstringPrev 2 Swing Sweepi_scr_choose
Paste SymbolstextNSE:ABCAPITAL,NSE:BIOCON,NSE:BLS,NSE:BOMDYEING,NSE:CAPACITE,i_symbols
Display Tablebooltruei_scr_show_table
Long Signalsbooltruei_scr_show_long
Short Signalsbooltruei_scr_show_short
Display Rowsint12i_scr_tbl_disp_rows
Table Positionstringposition.bottom_lefti_scr_tbl_position
Table Sizestringsize.smalli_scr_tbl_text_size
Display Zig Zagbooltruei_zz_display
Zig Zag Lengthint4i_zz_period
SourcestringHigh/Lowi_zz_source
Color Upcolor#1E53E5i_zz_bull_color
Show all 26 settings
SettingTypeDefaultVariable
Color Downcolor#1E53E5i_zz_bear_color
Line Stylestringline.style_solidi_zz_ln_style
Display Tablebooltruei_tbl_data_show
Positionstringposition.bottom_righti_tbl_data_pos
Sizestringsize.normali_tbl_data_txt_size
Positive Darkcolor#03110Fi_pos_dark_color
Positive Midcolor#26A69Ai_pos_color
Positive Lightcolor#ACE5DCi_pos_light_color
Negative Lightcolor#FCCBCDi_neg_light_color
Negative Midcolor#FF5252i_neg_color
Negative Darkcolor#180809i_neg_dark_color
Neutral Lightcolor#D1D4DCi_neu_color
Neutral Midcolor#2A2E39i_neu_mid_color
Neutral Darkcolor#141516i_neu_dark_color
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

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
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 2 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 2 months ago · MPL-2.0 GitHub repository of Apex Trend & Liquidity Master
23 stars

MTF State of Delivery tracks lower timeframe and higher timeframe orderflow delivery states by identifying bullish and bearish delivery levels across timeframes. It plots confirmed and pending orderflow lines directly on the price chart and provides an optiona

Indicator v5 SMC / ICT / price actionSupport & resistance
Updated 3 weeks ago · Custom licence GitHub repository of MTF State of Delivery by traderprimez

Bandz HTF

by samuelharting
18 stars

Bandz HTF projects higher-timeframe candle structures, ranges, and key levels directly onto the main price chart. It visualizes multiple configurable timeframe lanes from intraday to weekly alongside primary and macro range levels, including 25%, 50%, and 75%

Indicator v6 SMC / ICT / price actionSupport & resistance
Updated 2 weeks ago · MPL-2.0 GitHub repository of Bandz HTF

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