Indicator · Pine Script v6 · On the chart

Support/Resistance & Liquidity Zones

by PlasmaZero

This indicator finds pivot highs and lows with adjustable left and right bars and draws support and resistance zones as boxes on the price chart.

View on GitHub

GitHub stars1on the repository
Pine versionv6current
Lines of code242
Settings15inputs
LicenceNone statedfile: MPL-2.0
Last update11 months ago20 Nov 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

242 lines of Pine Script v6 from main.pine, published under MPL-2.0 (file header). Keep the author's credit and licence lines when you reuse it.

main.pine
// This Pine Script® code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © PlasmaZero

//@version=6
indicator("Support/Resistance & Liquidity Zones", overlay = true, max_lines_count = 500, max_boxes_count = 500)

// Inputs
leftBars   = input.int(5,  "Pivot Left Bars",  minval = 1, maxval = 20, group = "Pivot Settings")
rightBars  = input.int(5,  "Pivot Right Bars", minval = 1, maxval = 20, group = "Pivot Settings")
maxLevels  = input.int(5,  "Max Levels to Show", minval = 1, maxval = 20, group = "Pivot Settings")
lookback   = input.int(100, "Lookback Period (bars)", minval = 20, maxval = 500, group = "Pivot Settings")
extendBars = input.int(50,  "Extend Zones Right (bars)", minval = 10, maxval = 200, group = "Pivot Settings")

showSupport    = input.bool(true,  "Show Support Zones (S)", group = "Display")
showResistance = input.bool(true,  "Show Resistance Zones (R)", group = "Display")
showLiquidity  = input.bool(true,  "Show Liquidity Zones (L)", group = "Display")
showLabels     = input.bool(true,  "Show Zone Labels", group = "Display")
showStrength   = input.bool(true,  "Show Level Strength", group = "Display")

volThreshold   = input.int(150,    "Volume Threshold %", minval = 100, maxval = 300, group = "Liquidity")
zoneWidth      = input.float(0.5,  "Zone Width %", minval = 0.1, maxval = 5.0, group = "Liquidity")

supColor       = input.color(color.new(color.green, 80), "Support Zone", group = "Colors")
resColor       = input.color(color.new(color.red, 80),   "Resistance Zone", group = "Colors")
liqColor       = input.color(color.new(color.blue, 85),  "Liquidity Zone", group = "Colors")

// Pivot detection
ph = ta.pivothigh(high, leftBars, rightBars)
pl = ta.pivotlow(low,  leftBars, rightBars)

// Volume stuff
avgVol = ta.sma(volume, 20)
highVol = volume > avgVol * (volThreshold / 100)

// Storage arrays
var box[] resBoxes = array.new_box()
var box[] supBoxes = array.new_box()
var box[] liqBoxes = array.new_box()

var label[] resLabels = array.new_label()
var label[] supLabels = array.new_label()
var label[] liqLabels = array.new_label()

var float[] resLevels = array.new_float()
var float[] supLevels = array.new_float()
var int[]   resTouches = array.new_int()
var int[]   supTouches = array.new_int()

// Helper functions
getStrength(touches) =>
    touches <= 2 ? "●" : touches <= 4 ? "●●" : "●●●"

nearLevel(price, level, tolerance) =>
    math.abs(price - level) / level < tolerance / 100

// Check if new pivot matches an existing level
findExistingLevel(levels, newLevel, tolerance) =>
    int foundIdx = -1
    if array.size(levels) > 0
        for i = 0 to array.size(levels) - 1
            if nearLevel(newLevel, array.get(levels, i), tolerance)
                foundIdx := i
                break
    foundIdx

// Resistance zones
if showResistance and not na(ph)
    int   x  = bar_index - rightBars
    float y  = ph
    float y2 = y * (1 + zoneWidth / 100)
    
    // Only track recent pivots
    if bar_index - x <= lookback
        existingIdx = findExistingLevel(resLevels, y, zoneWidth * 2)
        
        if existingIdx >= 0
            // Update the existing level
            currentTouches = array.get(resTouches, existingIdx)
            array.set(resTouches, existingIdx, currentTouches + 1)
            
            // Update label with new strength
            if showLabels and array.size(resLabels) > existingIdx
                oldLabel = array.get(resLabels, existingIdx)
                label.delete(oldLabel)
                
                labelText = "R"
                if showStrength
                    labelText := labelText + " " + getStrength(currentTouches + 1)
                
                newLabel = label.new(
                     x = bar_index,
                     y = array.get(resLevels, existingIdx),
                     text = labelText,
                     style = label.style_label_down,
                     color = color.new(color.red, 30),
                     textcolor = color.white,
                     size = size.small
                 )
                array.set(resLabels, existingIdx, newLabel)
        else
            // New level - check if it's a liquidity zone
            isLiqZone = highVol and showLiquidity
            
            box b = box.new(
                 left   = x,
                 top    = y2,
                 right  = bar_index + extendBars,
                 bottom = y,
                 bgcolor = isLiqZone ? liqColor : resColor,
                 border_color = isLiqZone ? color.new(color.blue, 40) : color.new(color.red, 40),
                 border_width = isLiqZone ? 2 : 1
             )
            array.push(isLiqZone ? liqBoxes : resBoxes, b)
            
            array.push(resLevels, y)
            array.push(resTouches, 1)
            
            if showLabels
                labelText = isLiqZone ? "L" : "R"
                if showStrength
                    labelText := labelText + " " + getStrength(1)
                
                lbl = label.new(
                     x = bar_index,
                     y = y,
                     text = labelText,
                     style = label.style_label_down,
                     color = isLiqZone ? color.new(color.blue, 30) : color.new(color.red, 30),
                     textcolor = color.white,
                     size = size.small
                 )
                array.push(isLiqZone ? liqLabels : resLabels, lbl)
            
            // Clean up old zones
            if array.size(isLiqZone ? liqBoxes : resBoxes) > maxLevels
                box old = array.shift(isLiqZone ? liqBoxes : resBoxes)
                box.delete(old)
                array.shift(resLevels)
                array.shift(resTouches)
                if showLabels
                    label oldLbl = array.shift(isLiqZone ? liqLabels : resLabels)
                    label.delete(oldLbl)

// Support zones
if showSupport and not na(pl)
    int   x  = bar_index - rightBars
    float y  = pl
    float y2 = y * (1 - zoneWidth / 100)
    
    // Only track recent pivots
    if bar_index - x <= lookback
        existingIdx = findExistingLevel(supLevels, y, zoneWidth * 2)
        
        if existingIdx >= 0
            // Update the existing level
            currentTouches = array.get(supTouches, existingIdx)
            array.set(supTouches, existingIdx, currentTouches + 1)
            
            // Update label with new strength
            if showLabels and array.size(supLabels) > existingIdx
                oldLabel = array.get(supLabels, existingIdx)
                label.delete(oldLabel)
                
                labelText = "S"
                if showStrength
                    labelText := labelText + " " + getStrength(currentTouches + 1)
                
                newLabel = label.new(
                     x = bar_index,
                     y = array.get(supLevels, existingIdx),
                     text = labelText,
                     style = label.style_label_up,
                     color = color.new(color.green, 30),
                     textcolor = color.white,
                     size = size.small
                 )
                array.set(supLabels, existingIdx, newLabel)
        else
            // New level - check if it's a liquidity zone
            isLiqZone = highVol and showLiquidity
            
            box b = box.new(
                 left   = x,
                 top    = y,
                 right  = bar_index + extendBars,
                 bottom = y2,
                 bgcolor = isLiqZone ? liqColor : supColor,
                 border_color = isLiqZone ? color.new(color.blue, 40) : color.new(color.green, 40),
                 border_width = isLiqZone ? 2 : 1
             )
            array.push(isLiqZone ? liqBoxes : supBoxes, b)
            
            array.push(supLevels, y)
            array.push(supTouches, 1)
            
            if showLabels
                labelText = isLiqZone ? "L" : "S"
                if showStrength
                    labelText := labelText + " " + getStrength(1)
                
                lbl = label.new(
                     x = bar_index,
                     y = y,
                     text = labelText,
                     style = label.style_label_up,
                     color = isLiqZone ? color.new(color.blue, 30) : color.new(color.green, 30),
                     textcolor = color.white,
                     size = size.small
                 )
                array.push(isLiqZone ? liqLabels : supLabels, lbl)
            
            // Clean up old zones
            if array.size(isLiqZone ? liqBoxes : supBoxes) > maxLevels
                box old = array.shift(isLiqZone ? liqBoxes : supBoxes)
                box.delete(old)
                array.shift(supLevels)
                array.shift(supTouches)
                if showLabels
                    label oldLbl = array.shift(isLiqZone ? liqLabels : supLabels)
                    label.delete(oldLbl)

// Pivot markers
plotshape(not na(ph) and showResistance, 
     title = "Pivot High",
     style = shape.triangledown, 
     location = location.abovebar,
     color = color.new(color.red, 20), 
     size = size.tiny)

plotshape(not na(pl) and showSupport, 
     title = "Pivot Low",
     style = shape.triangleup, 
     location = location.belowbar,
     color = color.new(color.green, 20), 
     size = size.tiny)

// Alerts
breakResistance = ta.crossover(close, ta.highest(high, 20))
breakSupport = ta.crossunder(close, ta.lowest(low, 20))

alertcondition(breakResistance, "Resistance Break", "Price broke resistance level")
alertcondition(breakSupport, "Support Break", "Price broke support level")

Overview

Repeated touches of a level raise a strength rating shown as dots. High-volume bars, measured against a 20-bar average with a percentage threshold, create liquidity zones. Zone width, lookback, how far boxes extend right, the number of levels and the colours are adjustable. Pivots confirm after the right bars have formed.

Details

Published by

PlasmaZero on GitHub

Type

Indicator, Pine Script v6

Draws

On the price chart

Category

Support & resistance, Volume

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
Pivot Left Barsint5leftBars
Pivot Right Barsint5rightBars
Max Levels to Showint5maxLevels
Lookback Period (bars)int100lookback
Extend Zones Right (bars)int50extendBars
Show Support Zones (S)booltrueshowSupport
Show Resistance Zones (R)booltrueshowResistance
Show Liquidity Zones (L)booltrueshowLiquidity
Show Zone LabelsbooltrueshowLabels
Show Level StrengthbooltrueshowStrength
Volume Threshold %int150volThreshold
Zone Width %float0.5zoneWidth
Show all 15 settings
SettingTypeDefaultVariable
Support Zonecolorcolor.new(color.green, 80)supColor
Resistance Zonecolorcolor.new(color.red, 80)resColor
Liquidity Zonecolorcolor.new(color.blue, 85)liqColor
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 overlay indicator draws a fixed-range volume profile on the price chart, splitting traded activity into up and down volume at each price level. It also plots a sentiment profile, a developing point of control, and value-area high and low around a configur

Indicator v5 VolumeSupport & resistance
Updated 2 months ago · MIT GitHub repository of Volume Profile and Indicator by DGT

MGIC-tracker

by Allen1212
303 stars

The MGIC-tracker is a TradingView indicator that overlays ARK Invest trade records onto stock price charts. It plots buy and sell labels at the exact timestamp of each transaction, showing share volume and ETF weight. Users select a specific ETF type via setti

Indicator v4 Support & resistanceVolume
Updated 2 years ago · None stated GitHub repository of MGIC-tracker
218 stars

Comprehensive Volume Profile is an overlay indicator that calculates and plots volume distribution across specified time ranges such as daily sessions, weekly, monthly, or custom bar lengths. It identifies key structural price levels including the Point of Con

Indicator v6 VolumeSupport & resistance
Updated 3 months ago · None stated GitHub repository of Comprehensive Volume Profile

Moon Dev GEX Arrows

by moondevonyt
92 stars

This overlay indicator plots option strike walls and an optional session VWAP on the price chart for SPY or ES. It spaces major strikes by the selected instrument, draws a set number of strikes on each side, and marks wall-trap and sweep events after a cooldow

Indicator v5 Support & resistanceSessions & time
Updated 2 months ago · Custom licence GitHub repository of Moon Dev GEX Arrows

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