OPEN-SOURCE SCRIPT
Support Resistance Zone Selvapandi

//version=5
indicator("Volume Footprint S/R Zones – Nifty (Syntax Safe)", overlay=true, max_boxes_count=300)
// ---------- Inputs ----------
volLen = input.int(50, "Volume MA Length")
volMult = input.float(1.8, "Volume Spike Multiplier", step=0.1)
bodyPctMin = input.float(0.6, "Impulse Body %", step=0.05)
atrLen = input.int(14, "ATR Length")
zoneATRmult = input.float(0.7, "Zone Height ATR Mult", step=0.1)
extendBars = input.int(200, "Extend Zones (bars)")
maxRetests = input.int(3, "Max Retests per Zone")
// ---------- Core Metrics ----------
volMA = ta.sma(volume, volLen)
atr = ta.atr(atrLen)
isVolSpike = volume > volMA * volMult
body = math.abs(close - open)
barRange = high - low
bodyPct = barRange > 0 ? body / barRange : 0.0
bullImpulse = close > open and bodyPct >= bodyPctMin and isVolSpike
bearImpulse = close < open and bodyPct >= bodyPctMin and isVolSpike
zoneSize = atr * zoneATRmult
// ---------- Storage ----------
var box[] zones = array.new_box()
var float[] zTop = array.new_float()
var float[] zBot = array.new_float()
var int[] zType = array.new_int()
var int[] zTests = array.new_int()
var bool[] zActive = array.new_bool()
// ---------- Create Zone Function ----------
create_zone(_top, _bot, _type) =>
b = box.new(bar_index, _top, bar_index + extendBars, _bot, bgcolor = _type == 1 ? color.new(color.green,85) : color.new(color.red,85), border_color = _type == 1 ? color.green : color.red)
array.push(zones, b)
array.push(zTop, _top)
array.push(zBot, _bot)
array.push(zType, _type)
array.push(zTests, 0)
array.push(zActive, true)
// ---------- Zone Creation ----------
if bullImpulse
create_zone(low + zoneSize, low, 1)
if bearImpulse
create_zone(high, high - zoneSize, -1)
// ---------- Zone Management ----------
longRetestSignal = false
shortRetestSignal = false
zoneCount = array.size(zones)
if zoneCount > 0
for i = 0 to zoneCount - 1
if array.get(zActive, i)
top = array.get(zTop, i)
bot = array.get(zBot, i)
typ = array.get(zType, i)
bx = array.get(zones, i)
touched = low <= top and high >= bot
if touched
tests = array.get(zTests, i) + 1
array.set(zTests, i, tests)
if tests <= maxRetests
if typ == 1
longRetestSignal := true
if typ == -1
shortRetestSignal := true
if typ == 1 and close < bot
array.set(zType, i, -1)
box.set_bgcolor(bx, color.new(color.orange,85))
box.set_border_color(bx, color.orange)
if typ == -1 and close > top
array.set(zType, i, 1)
box.set_bgcolor(bx, color.new(color.teal,85))
box.set_border_color(bx, color.teal)
if array.get(zTests, i) > maxRetests
array.set(zActive, i, false)
box.set_bgcolor(bx, color.new(color.gray,92))
box.set_border_color(bx, color.gray)
// ---------- Visual Signals ----------
plotshape(longRetestSignal, title="Support Retest", style=shape.triangleup, location=location.belowbar, color=color.lime, size=size.small)
plotshape(shortRetestSignal, title="Resistance Retest", style=shape.triangledown, location=location.abovebar, color=color.red, size=size.small)
// ---------- Alerts ----------
alertcondition(longRetestSignal, title="Support Zone Retest", message="Price retesting high-volume support zone")
alertcondition(shortRetestSignal, title="Resistance Zone Retest", message="Price retesting high-volume resistance zone")
indicator("Volume Footprint S/R Zones – Nifty (Syntax Safe)", overlay=true, max_boxes_count=300)
// ---------- Inputs ----------
volLen = input.int(50, "Volume MA Length")
volMult = input.float(1.8, "Volume Spike Multiplier", step=0.1)
bodyPctMin = input.float(0.6, "Impulse Body %", step=0.05)
atrLen = input.int(14, "ATR Length")
zoneATRmult = input.float(0.7, "Zone Height ATR Mult", step=0.1)
extendBars = input.int(200, "Extend Zones (bars)")
maxRetests = input.int(3, "Max Retests per Zone")
// ---------- Core Metrics ----------
volMA = ta.sma(volume, volLen)
atr = ta.atr(atrLen)
isVolSpike = volume > volMA * volMult
body = math.abs(close - open)
barRange = high - low
bodyPct = barRange > 0 ? body / barRange : 0.0
bullImpulse = close > open and bodyPct >= bodyPctMin and isVolSpike
bearImpulse = close < open and bodyPct >= bodyPctMin and isVolSpike
zoneSize = atr * zoneATRmult
// ---------- Storage ----------
var box[] zones = array.new_box()
var float[] zTop = array.new_float()
var float[] zBot = array.new_float()
var int[] zType = array.new_int()
var int[] zTests = array.new_int()
var bool[] zActive = array.new_bool()
// ---------- Create Zone Function ----------
create_zone(_top, _bot, _type) =>
b = box.new(bar_index, _top, bar_index + extendBars, _bot, bgcolor = _type == 1 ? color.new(color.green,85) : color.new(color.red,85), border_color = _type == 1 ? color.green : color.red)
array.push(zones, b)
array.push(zTop, _top)
array.push(zBot, _bot)
array.push(zType, _type)
array.push(zTests, 0)
array.push(zActive, true)
// ---------- Zone Creation ----------
if bullImpulse
create_zone(low + zoneSize, low, 1)
if bearImpulse
create_zone(high, high - zoneSize, -1)
// ---------- Zone Management ----------
longRetestSignal = false
shortRetestSignal = false
zoneCount = array.size(zones)
if zoneCount > 0
for i = 0 to zoneCount - 1
if array.get(zActive, i)
top = array.get(zTop, i)
bot = array.get(zBot, i)
typ = array.get(zType, i)
bx = array.get(zones, i)
touched = low <= top and high >= bot
if touched
tests = array.get(zTests, i) + 1
array.set(zTests, i, tests)
if tests <= maxRetests
if typ == 1
longRetestSignal := true
if typ == -1
shortRetestSignal := true
if typ == 1 and close < bot
array.set(zType, i, -1)
box.set_bgcolor(bx, color.new(color.orange,85))
box.set_border_color(bx, color.orange)
if typ == -1 and close > top
array.set(zType, i, 1)
box.set_bgcolor(bx, color.new(color.teal,85))
box.set_border_color(bx, color.teal)
if array.get(zTests, i) > maxRetests
array.set(zActive, i, false)
box.set_bgcolor(bx, color.new(color.gray,92))
box.set_border_color(bx, color.gray)
// ---------- Visual Signals ----------
plotshape(longRetestSignal, title="Support Retest", style=shape.triangleup, location=location.belowbar, color=color.lime, size=size.small)
plotshape(shortRetestSignal, title="Resistance Retest", style=shape.triangledown, location=location.abovebar, color=color.red, size=size.small)
// ---------- Alerts ----------
alertcondition(longRetestSignal, title="Support Zone Retest", message="Price retesting high-volume support zone")
alertcondition(shortRetestSignal, title="Resistance Zone Retest", message="Price retesting high-volume resistance zone")
Open-source script
In true TradingView spirit, the creator of this script has made it open-source, so that traders can review and verify its functionality. Kudos to the author! While you can use it for free, remember that republishing the code is subject to our House Rules.
Disclaimer
The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.
Open-source script
In true TradingView spirit, the creator of this script has made it open-source, so that traders can review and verify its functionality. Kudos to the author! While you can use it for free, remember that republishing the code is subject to our House Rules.
Disclaimer
The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.