Indicator · Pine Script v4 · On the chart

TPCharts Liquidity Range

by TPCharts

TPCharts Liquidity Range calculates and plots significant liquidity levels over a specified historical period and resolution directly on the main price chart.

View on GitHub

Repaints

GitHub stars10on the repository
Pine versionv4older, still runs
Lines of code144
Settings15inputs
LicenceGPL-3.0
Last update5 years ago1 Dec 2020

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

144 lines of Pine Script v4 from TPCharts-Liquidity-Range.pine, published under GPL-3.0. Keep the author's credit and licence lines when you reuse it.

TPCharts-Liquidity-Range.pine
//@version=4
study(title="TPCharts Liquidity Range", overlay=true)

resolution = input(title="Resolution", type=input.resolution, defval="D")
period = input(title="Period", type=input.integer, defval=20)

isPDHLShown = input(title="Show Previous Day's Highs and Lows?", type=input.bool, defval=true)
isPDHLLabelShown = input(title="Show PDHL labels?", type=input.bool, defval=true)
isPDHLLabelDescriptorShown = input(title="Show PDHL Label Descriptor?", type=input.bool, defval=true)
isPDHLPriceShown = input(title="Show PDHL prices?", type=input.bool, defval=true)

isNumbersShown = input(title="Show Candle Numbers?", type=input.bool, defval=false)

isEQShown = input(title="Show Range EQ?", type=input.bool, defval=true)
isEQLabelShown = input(title="Show EQ Label?", type=input.bool, defval=true)
isEQLabelDescriptorShown = input(title="Show EQ Label Descriptor?", type=input.bool, defval=true)
isEQPriceShown = input(title="Show EQ Price?", type=input.bool, defval=true)

isRangeLabelShown = input(title="Show Range Label?", type=input.bool, defval=true)
isRangeLabelDescriptorShown = input(title="Show Range Label Descriptor?", type=input.bool, defval=true)
isRangePriceShown = input(title="Show Range Price?", type=input.bool, defval=true)

isSundayIgnored = input(title="Ignore Sunday (don't use on Sunday then)?", type=input.bool, defval=false)

isCurrentDay = security(syminfo.tickerid, "D", barstate.islast)

pdh = security(syminfo.tickerid, "D", high[1])
pdl = security(syminfo.tickerid, "D", low[1])
tdot = security(syminfo.tickerid, "D", time[1]) 

periodOffset() => (isSundayIgnored and syminfo.type != 'forex' ? (dayofweek(timenow) == dayofweek.saturday ? floor(period / 7) + 1 : floor(period / 7)) : 0)

rangeStartTime = security(syminfo.tickerid, "D", time[period+periodOffset()])


// Ignoring Sundays

// How many sundays are there?
// floor(period/7) UNLESS today is a sunday, then add one


rangeHighPrice = security(syminfo.tickerid, resolution, highest(high, period+1+periodOffset()), lookahead=barmerge.lookahead_on)
rangeLowPrice = security(syminfo.tickerid, resolution, lowest(low, period+1+periodOffset()), lookahead=barmerge.lookahead_on)
rangeEQPrice = rangeHighPrice - ((rangeHighPrice - rangeLowPrice) / 2)

alertcondition(crossover(high, rangeHighPrice) or crossunder(low, rangeHighPrice), title="Liq range high cross", message="Liq range high cross")
alertcondition(crossover(high, rangeLowPrice) or crossunder(low, rangeLowPrice), title="Liq range low cross", message="Liq range low cross")
alertcondition(crossover(high, rangeEQPrice) or crossunder(low, rangeEQPrice), title="Liq range EQ cross", message="Liq range EQ cross")


labelDayOffset = 2
timelocOffset = time+(86400000 * labelDayOffset)

var eqLabelText = ""
var pdhLabelText = ""
var pdlLabelText = ""
var rangeHighLabelText = ""
var rangeLowLabelText = ""


line rangeHighLine = na
label rangeHighLabel = na

line rangeLowLine = na
label rangeLowLabel = na

line PDHLHighLine = na
label PDHLHighLabel = na

line PDHLLowLine = na
label PDHLLowLabel = na

line eqLine = na
label eqLabel = na

if isCurrentDay
    rangeHighLine := line.new(x1=rangeStartTime, y1=rangeHighPrice, x2=timelocOffset, y2=rangeHighPrice, extend=extend.right, color=color.black, xloc=xloc.bar_time)
    line.delete(rangeHighLine[1])
    
    rangeLowLine := line.new(x1=rangeStartTime, y1=rangeLowPrice, x2=timelocOffset, y2=rangeLowPrice, extend=extend.right, color=color.black, xloc=xloc.bar_time)
    line.delete(rangeLowLine[1])

    if isRangeLabelShown
        if isRangePriceShown
            rangeHighLabelText := tostring(rangeHighPrice)
            rangeLowLabelText := tostring(rangeLowPrice)

        if isRangeLabelDescriptorShown
            rangeHighLabelText := "Liq Range High" + (rangeHighLabelText == "" ? "" : " (" + rangeHighLabelText + ")") 
            rangeLowLabelText := "Liq Range Low" + (rangeLowLabelText == "" ? "" : " (" + rangeLowLabelText + ")") 

        rangeHighLabel := label.new(rangeStartTime, rangeHighPrice, text=rangeHighLabelText, style=label.style_none, xloc=xloc.bar_time)
        label.delete(rangeHighLabel[1])

        rangeLowLabel := label.new(rangeStartTime, rangeLowPrice, text=rangeLowLabelText, style=label.style_none, xloc=xloc.bar_time)
        label.delete(rangeLowLabel[1])

    if isPDHLShown
        PDHLHighLine := line.new(x1=tdot, y1=pdh, x2=timelocOffset, y2=pdh, extend=extend.right, color=color.black, style=line.style_dotted, width=1, xloc=xloc.bar_time)
        line.delete(PDHLHighLine[1])

        PDHLLowLine := line.new(x1=tdot, y1=pdl, x2=timelocOffset, y2=pdl, extend=extend.right, color=color.black, style=line.style_dotted, width=1, xloc=xloc.bar_time)
        line.delete(PDHLLowLine[1])

        if isPDHLLabelShown
            if isPDHLPriceShown
                pdhLabelText := tostring(pdh)
                pdlLabelText := tostring(pdl)

            if isPDHLLabelDescriptorShown
                pdhLabelText := "PDH" + (pdhLabelText == "" ? "" : " (" + pdhLabelText + ")") 
                pdlLabelText := "PDL" + (pdlLabelText == "" ? "" : " (" + pdlLabelText + ")") 

            if isPDHLLabelShown
                PDHLHighLabel := label.new(timelocOffset, pdh, text=pdhLabelText, style=label.style_none,xloc=xloc.bar_time)
                label.delete(PDHLHighLabel[1])

                PDHLLowLabel := label.new(timelocOffset, pdl, text=pdlLabelText, style=label.style_none, xloc=xloc.bar_time)
                label.delete(PDHLLowLabel[1])

    if isNumbersShown and timeframe.period == "D"
        var counter = 0
        for i=0 to period+periodOffset()
            if i>0
                barTime = time[i]
                if dayofweek(barTime) == dayofweek.sunday and isSundayIgnored
                    label.new(bar_index-i, high[i], "Sun", color=color.black, yloc=yloc.abovebar, textcolor=color.white)
                else
                    counter := counter + 1
                    label.new(bar_index-i, high[i], tostring(counter), color=color.black, yloc=yloc.abovebar, textcolor=color.white)

    if isEQShown
        eqLine := line.new(x1=rangeStartTime, y1=rangeEQPrice, x2=timelocOffset, y2=rangeEQPrice, extend=extend.right, color=color.blue, width=1, xloc=xloc.bar_time)
        line.delete(eqLine[1])

        if isEQLabelShown
            if isEQPriceShown
                eqLabelText := tostring(rangeEQPrice)

            if isEQLabelDescriptorShown
                eqLabelText := "Liq Range EQ" + (eqLabelText == "" ? "" : " (" + eqLabelText + ")") 

            eqLabel := label.new(rangeStartTime, rangeEQPrice, text=eqLabelText, style=label.style_none, color=color.blue, textcolor=color.blue, xloc=xloc.bar_time)
            label.delete(eqLabel[1])

Overview

TPCharts Liquidity Range highlights the range high, range low, and the 50% range equilibrium level, as well as the previous day's high and low prices. Customization options allow users to toggle labels, prices, candle numbers, and optionally exclude Sunday data. Alerts trigger when price crosses the range high, range low, or equilibrium. The indicator utilizes higher-timeframe security calls with lookahead enabled, which introduces lookahead bias on historical bars.

Details

Published by

TPCharts on GitHub

Type

Indicator, Pine Script v4

Draws

On the price chart

Category

Support & resistance, SMC / ICT / price action

Markets

Any symbol

Timeframes

Any timeframe

Risk Notes

  • Reads higher-timeframe data with lookahead on, so the history can show signals that were not there in real time

Settings

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

SettingTypeDefaultVariable
ResolutiontimeframeDresolution
Periodint20period
Show Previous Day's Highs and Lows?booltrueisPDHLShown
Show PDHL labels?booltrueisPDHLLabelShown
Show PDHL Label Descriptor?booltrueisPDHLLabelDescriptorShown
Show PDHL prices?booltrueisPDHLPriceShown
Show Candle Numbers?boolfalseisNumbersShown
Show Range EQ?booltrueisEQShown
Show EQ Label?booltrueisEQLabelShown
Show EQ Label Descriptor?booltrueisEQLabelDescriptorShown
Show EQ Price?booltrueisEQPriceShown
Show Range Label?booltrueisRangeLabelShown
Show all 15 settings
SettingTypeDefaultVariable
Show Range Label Descriptor?booltrueisRangeLabelDescriptorShown
Show Range Price?booltrueisRangePriceShown
Ignore Sunday (don't use on Sunday then)?boolfalseisSundayIgnored
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 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

DE-tracker

by Allen1212
303 stars

This indicator plots labels on the TradingView price chart to mark ARK Invest's buy and sell trades for the DE stock. Buy transactions appear in green with X1 or X2 multipliers showing the number of ARK ETFs involved on the same day; sells appear in red. The m

Indicator v4 Support & resistanceSMC / ICT / price action
Updated 2 years ago · None stated GitHub repository of DE-tracker

This Pine Script indicator plots a ZigZag on the price chart. It identifies reversal points when price moves more than a set percentage from the last pivot. The script calculates forecasts using zigzag data and labels detected geometric patterns including harm

Indicator v4 TrendSupport & resistance

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

Open Source Fractal

by cantolab
183 stars

This indicator implements the Fractal Model concept to plot market structure shifts, liquidity sweeps, and Change in State of Delivery (CISD) levels. It overlays custom higher-timeframe candle previews, open prices, and time markers directly on the price chart

Indicator v6 SMC / ICT / price actionSupport & resistance
Updated 2 months ago · MIT GitHub repository of Open Source Fractal

Swing Failure Signals

by Ganador1
154 stars

This indicator calculates pivot highs and pivot lows to detect liquidity sweeps and Swing Failure Patterns. It identifies when price breaks past recent key swing highs or lows within a configurable historical window, then looks for a quick reversal or change i

Indicator v6 SMC / ICT / price actionSupport & resistance
Updated 2 months ago · Apache-2.0 GitHub repository of Swing Failure Signals

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