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")
開源腳本
秉持TradingView一貫精神,這個腳本的創作者將其設為開源,以便交易者檢視並驗證其功能。向作者致敬!您可以免費使用此腳本,但請注意,重新發佈代碼需遵守我們的社群規範。
免責聲明
這些資訊和出版物並非旨在提供,也不構成TradingView提供或認可的任何形式的財務、投資、交易或其他類型的建議或推薦。請閱讀使用條款以了解更多資訊。
開源腳本
秉持TradingView一貫精神,這個腳本的創作者將其設為開源,以便交易者檢視並驗證其功能。向作者致敬!您可以免費使用此腳本,但請注意,重新發佈代碼需遵守我們的社群規範。
免責聲明
這些資訊和出版物並非旨在提供,也不構成TradingView提供或認可的任何形式的財務、投資、交易或其他類型的建議或推薦。請閱讀使用條款以了解更多資訊。