Library · Pine Script v5 · Library

LiquidityFinderLibrary

by alvinng214· code credited to TFlab

This Pine Script library exports a liquidity line detection function designed for Smart Money Concepts analysis.

View on GitHub

GitHub stars2on the repository
Pine versionv5runs as is
Lines of code88
Settings0inputs
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 library, select all of the template text and paste. Press Save and give it a name.
  4. 4Publish or import itA library draws nothing. Publish it from the editor, then import its functions in your own scripts.

Source Code

88 lines of Pine Script v5 from Smart Money Concept [TradingFinder] Major Minor OB + FVG (SMC)/TFlabLiquidityFinderLibrary1.txt, published under MPL-2.0 (file header). Keep the author's credit and licence lines when you reuse it.

TFlabLiquidityFinderLibrary1.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

library("LiquidityFinderLibrary", overlay = true)

export LLF(int sPP, int dPP , float SRs , float SRd , bool ShowHLLs ,bool ShowLLLs, bool ShowHLLd ,bool ShowLLLd) => //StaticsLiquidityLineFunction  {p = Previous , c = Current , s = Statics , d = Dynamics, SR = Sensitivity Range}
    //get data
    //Average true Range
    ATR = ta.atr(55)
    STSHighPivot = ta.pivothigh(sPP,sPP) // Short term Statics High Pivot Price {True or False}
    STSLowPivot = ta.pivotlow(sPP,sPP) // Short term Statics Low Pivot Price {True or False}
    STSHVc = ta.valuewhen(STSHighPivot ,high[sPP], 0) // Short term Statics High
    STSLVc = ta.valuewhen(STSLowPivot ,low[sPP], 0) // Short term Statics Low
    STSHIc = ta.valuewhen(STSHighPivot ,bar_index[sPP], 0) // Short term Statics High
    STSLIc = ta.valuewhen(STSLowPivot ,bar_index[sPP], 0) // Short term Statics Low
    STSHVp = ta.valuewhen(STSHighPivot ,high[sPP], 1) // Short term Statics High
    STSLVp = ta.valuewhen(STSLowPivot ,low[sPP], 1) // Short term Statics Low
    STSHIp = ta.valuewhen(STSHighPivot ,bar_index[sPP], 1) // Short term Statics High
    STSLIp = ta.valuewhen(STSLowPivot ,bar_index[sPP], 1) // Short term Statics Low
    DTSHighPivot = ta.pivothigh(dPP,dPP) // Short term Dynamics High Pivot Price {True or False}
    DTSLowPivot = ta.pivotlow(dPP,dPP) // Short term Dynamics Low Pivot Price {True or False}
    DTSHVc = ta.valuewhen(DTSHighPivot ,high[dPP], 0) // Short term Dynamics High
    DTSLVc = ta.valuewhen(DTSLowPivot ,low[dPP], 0) // Short term Dynamics Low
    DTSHIc = ta.valuewhen(DTSHighPivot ,bar_index[dPP], 0) // Short term Dynamics High
    DTSLIc = ta.valuewhen(DTSLowPivot ,bar_index[dPP], 0) // Short term Dynamics Low
    DTSHVp = ta.valuewhen(DTSHighPivot ,high[dPP], 1) // Short term Dynamics High
    DTSLVp = ta.valuewhen(DTSLowPivot ,low[dPP], 1) // Short term Dynamics Low
    DTSHIp = ta.valuewhen(DTSHighPivot ,bar_index[dPP], 1) // Short term Dynamicss High
    DTSLIp = ta.valuewhen(DTSLowPivot ,bar_index[dPP], 1) // Short term Dynamics Low   
    var line sHLL = na 
    var line sLLL = na 
    var label sHLLl = na 
    var label sLLLl = na 
    var line dHLL = na 
    var line dLLL = na 
    var label dHLLl = na 
    var label dLLLl= na 
    //STATICS/////////////////////////////////////////////////////////////////////////
    if STSHIc != STSHIc[1] and STSHVc <= STSHVp and (STSHIc - STSHIp) >= 8 and ShowHLLs
        if math.abs((STSHVp - STSHVc) / ATR[sPP]) <= SRs
            sHLL := line.new(x1 = STSHIp , y1 = STSHVp  , x2 =  STSHIc , y2 = STSHVp , color = color.rgb(18, 123, 184, 43) , style = line.style_dotted)
            sHLLl := label.new(x = math.round((STSHIp+STSHIc)/2) , y = STSHVp - (ATR/2), text = '2 Top Liq' , color = color.rgb(255, 255, 255, 100) ,
                 textcolor = color.rgb(18, 123, 184) , style = label.style_label_down , size = size.small)
    if STSLIc != STSLIc[1] and STSLVc >= STSLVp and (STSLIc - STSLIp) >= 8 and ShowLLLs
        if math.abs((STSLVp - STSLVc) / ATR[sPP]) <= SRs
            sLLL := line.new(x1 = STSLIp , y1 =STSLVp  , x2 =  STSLIc , y2 = STSLVp , color = color.rgb(162, 10, 233, 45), style = line.style_dotted)
            sLLLl := label.new(x = math.round((STSLIp+STSLIc)/2) , y = STSLVp+ (ATR/2), text = '2 Bottom Liq' , color = color.rgb(255, 255, 255, 100) ,
             textcolor = color.rgb(162, 10, 233) , style = label.style_label_up , size = size.small)
    //DYNAMICS/////////////////////////////////////////////////////////////////////////
    if DTSHIc != DTSHIc[1] and DTSHVc <= DTSHVp and (DTSHIc - DTSHIp) >= 4 and ShowHLLd
        if math.abs((DTSHVp - DTSHVc) / ATR[dPP]) >= SRd and math.abs((DTSHVp - DTSHVc) / ATR[dPP]) <= 1.95
            dHLL := line.new(x1 = DTSHIp , y1 = DTSHVp  , x2 =  DTSHIc , y2 = DTSHVc , color = color.rgb(18, 123, 184, 44) , style = line.style_dotted)
            dHLLl := label.new(x = math.round((DTSHIp+DTSHIc)/2)+2 , y = (DTSHVp + DTSHVc) / 2  - (ATR/4), text = 'DLiq' , color = color.rgb(255, 255, 255, 100) ,
                 textcolor = color.rgb(18, 123, 184) , style = label.style_label_down , size = size.small)
  
    if DTSLIc != DTSLIc[1] and DTSLVc >= DTSLVp and (DTSLIc - DTSLIp) >= 4 and ShowLLLd
        if math.abs((DTSLVp - DTSLVc) / ATR[dPP]) >= SRd and math.abs((DTSLVp - DTSLVc) / ATR[dPP]) <= 1.95
            dLLL := line.new(x1 = DTSLIp , y1 =DTSLVp  , x2 =  DTSLIc , y2 = DTSLVc , color = color.rgb(162, 10, 233, 45), style = line.style_dotted)
            dLLLl := label.new(x = math.round((DTSLIp+DTSLIc)/2)+2 , y = (DTSLVp + DTSLVp) / 2 + (ATR/4) , text = 'DLiq' , color = color.rgb(255, 255, 255, 100) ,
             textcolor = color.rgb(162, 10, 233) , style = label.style_label_up , size = size.small)

    if math.abs(line.get_x2(sHLL[1]) - line.get_x1(sHLL)) <= 2 
        line.delete(sHLL)
        label.delete(sHLLl[1])
        line.set_x2(sHLL[1] ,STSHIc)
        label.set_text(sHLLl,'3 Top Liq')
        label.set_x(sHLLl, math.abs( (line.get_x1(sHLL[1]) + line.get_x2(sHLL[1])) / 2 ) )

    if math.abs(line.get_x2(sLLL[1]) - line.get_x1(sLLL)) <= 2
        line.delete(sLLL)
        label.delete(sLLLl[1])
        line.set_x2(sLLL[1] ,STSLIc)
        label.set_text(sLLLl,'3 Top Liq')
        label.set_x(sLLLl, math.abs( (line.get_x1(sLLL[1]) + line.get_x2(sLLL[1])) / 2 ) )       

    if math.abs(line.get_x2(dHLL[1]) - line.get_x1(dHLL)) <= dPP*2 + 1
        line.delete(dHLL)
        label.delete(dHLLl[1])
        line.set_xy2(dHLL[1] ,DTSHIc , DTSHVc)
        label.set_xy(dHLLl, math.abs( ((line.get_x1(dHLL[1]) + line.get_x2(dHLL[1])) / 2)+2 ) , (line.get_y1(dHLL[1]) + line.get_y2(dHLL[1])) / 2 ) 

    if math.abs(line.get_x2(dLLL[1]) - line.get_x1(dLLL))  <= dPP*2 + 1
        line.delete(dLLL)
        label.delete(dLLLl[1])
        line.set_xy2(dLLL[1] ,DTSLIc , DTSLVc)
        label.set_xy(dLLLl, math.abs( ((line.get_x1(dLLL[1]) + line.get_x2(dLLL[1])) / 2)+2) , (line.get_y1(dLLL[1]) + line.get_y2(dLLL[1])) / 2 )

Overview

LiquidityFinderLibrary identifies static and dynamic pivot highs and lows over customizable lookback periods, normalizing price differences between consecutive swing points using an Average True Range filter. When swings align within sensitivity thresholds, it plots dotted liquidity lines and descriptive labels on the price chart to mark equal highs and equal lows. As a library, it provides modular chart visualization functions for external scripts.

Details

Published by

alvinng214 on GitHub

Code credit

TFlab, as written in the script's header

Type

Library, Pine Script v5

Draws

Library (no plots)

Category

SMC / ICT / price action, Support & resistance

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.

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

SMC Engine Private

by skipp-dev
1 stars

This Pine Script v6 library serves as an internal engine for Smart Money Concepts (SMC), providing types, tracking, and rendering logic for order blocks, fair value gaps, and market structure. It calculates order block parameters including quality scores, heig

Library v6 SMC / ICT / price actionSupport & resistance
Updated 2 days ago · None stated GitHub repository of SMC Engine Private

SFA FlowLiquidity v1

by genesisgrubio39
1 stars

The SFA FlowLiquidity library computes structural flow and liquidity events from price data. It detects sweep ups and downs with associated scores, identifies liquidity levels, and applies session and regime filters. Persistent arrays track liquidity prices, b

Library v6 SMC / ICT / price actionSupport & resistance
Updated 10 months ago · None stated GitHub repository of SFA FlowLiquidity v1

AuthLib

by alboogycOdR
6 stars

AuthLib is a Pine Script utility library providing access control and state management structures for technical indicators. It checks callers against a hardcoded array of authorized TradingView usernames before executing operations. The library exports user-de

Library v5 SMC / ICT / price actionSessions & time
Updated 7 months ago · None stated GitHub repository of AuthLib

PineDraw

by 345-strategies
5 stars

PineDraw is a Pine Script v6 library that provides object primitives for drawing and updating price levels on the chart. It enables indicators and strategies to maintain lines, boxes, and labels in place by updating existing objects instead of deleting and rec

Library v6 Support & resistance
Updated 2 days ago · MPL-2.0 GitHub repository of PineDraw

ZigZag

by rubystar0512
5 stars

This library calculates ZigZag pivots and draws connecting lines on the price chart. It changes direction when price moves beyond a percentage deviation after a set pivot depth, then stores each pivot with optional labels for reversal price, cumulative volume,

Library v5 Support & resistance
Updated 2 years ago · None stated GitHub repository of ZigZag

ICT Equal Highs and Lows

by ArunKBhaskar
575 stars

This overlay indicator finds pivot highs and lows on the price chart and compares the last two highs and the last two lows. When the percentage difference between a pair is below the Equal HL threshold, it treats them as equal levels and draws a box. Left and

Indicator v5 SMC / ICT / price actionSupport & resistance
Updated 1 year ago · MPL-2.0 GitHub repository of ICT Equal Highs and Lows

More libraries

Trade Your Charts With a Regulated Broker

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

Compare brokers