OPEN-SOURCE SCRIPT
Auto Volume Footprint S/R ZONES PRO

//version=5
indicator("Auto Volume Footprint S/R ZONES PRO", overlay=true, max_boxes_count=200)
// ————— Inputs
volMult = input.float(1.8, "Volume Spike Multiplier", step=0.1)
rangeMult = input.float(1.4, "Range Spike Multiplier", step=0.1)
pivotLen = input.int(3, "Pivot Length")
atrMult = input.float(0.4, "Zone Thickness ATR Mult", step=0.1)
extendRight = input.int(300, "Extend Bars Right")
minScore = input.float(1.2, "Min Volume Score Filter")
showLabels = input.bool(true, "Show Strength Labels")
enableAlerts = input.bool(true, "Enable Retest Alerts")
// ————— Base Metrics
avgVol = ta.sma(volume, 20)
avgRange = ta.sma(high-low, 20)
atr = ta.atr(14)
volScore = volume / avgVol
rangeScore = (high-low) / avgRange
volSpike = volScore > volMult
rangeSpike = rangeScore > rangeMult
pivotH = ta.pivothigh(high, pivotLen, pivotLen)
pivotL = ta.pivotlow(low, pivotLen, pivotLen)
priceBasis = (high + low + close*2) / 4
zoneHalf = atr * atrMult
// ————— Storage
var box[] zones = array.new_box()
var float[] tops = array.new_float()
var float[] bots = array.new_float()
// ————— Function create zone
createZone(_top, _bot, _color, _score) =>
b = box.new(bar_index-pivotLen, _top, bar_index+extendRight, _bot,
bgcolor=color.new(_color, 85),
border_color=_color)
array.push(zones, b)
array.push(tops, _top)
array.push(bots, _bot)
if showLabels
label.new(bar_index-pivotLen, _top,
text="Score "+str.tostring(_score, format.mintick),
style=label.style_label_down,
color=_color,
textcolor=color.white,
size=size.tiny)
// ————— Resistance Zone
if not na(pivotH) and volSpike[pivotLen] and rangeSpike[pivotLen] and volScore[pivotLen] > minScore
p = priceBasis[pivotLen]
top = p + zoneHalf
bot = p - zoneHalf
createZone(top, bot, color.red, volScore[pivotLen])
// ————— Support Zone
if not na(pivotL) and volSpike[pivotLen] and rangeSpike[pivotLen] and volScore[pivotLen] > minScore
p = priceBasis[pivotLen]
top = p + zoneHalf
bot = p - zoneHalf
createZone(top, bot, color.green, volScore[pivotLen])
// ————— Zone Maintenance + Break Detection
breakBuf = atr * 0.25
for i = 0 to array.size(zones)-1
z = array.get(zones, i)
t = array.get(tops, i)
b = array.get(bots, i)
broken = close > t + breakBuf or close < b - breakBuf
if broken
box.set_border_color(z, color.gray)
box.set_bgcolor(z, color.new(color.gray, 90))
// ————— Retest Alert Logic
retest = false
for i = 0 to array.size(tops)-1
t = array.get(tops, i)
b = array.get(bots, i)
if low <= t and high >= b
retest := true
alertcondition(enableAlerts and retest, "Zone Retest", "Price retesting volume S/R zone")
indicator("Auto Volume Footprint S/R ZONES PRO", overlay=true, max_boxes_count=200)
// ————— Inputs
volMult = input.float(1.8, "Volume Spike Multiplier", step=0.1)
rangeMult = input.float(1.4, "Range Spike Multiplier", step=0.1)
pivotLen = input.int(3, "Pivot Length")
atrMult = input.float(0.4, "Zone Thickness ATR Mult", step=0.1)
extendRight = input.int(300, "Extend Bars Right")
minScore = input.float(1.2, "Min Volume Score Filter")
showLabels = input.bool(true, "Show Strength Labels")
enableAlerts = input.bool(true, "Enable Retest Alerts")
// ————— Base Metrics
avgVol = ta.sma(volume, 20)
avgRange = ta.sma(high-low, 20)
atr = ta.atr(14)
volScore = volume / avgVol
rangeScore = (high-low) / avgRange
volSpike = volScore > volMult
rangeSpike = rangeScore > rangeMult
pivotH = ta.pivothigh(high, pivotLen, pivotLen)
pivotL = ta.pivotlow(low, pivotLen, pivotLen)
priceBasis = (high + low + close*2) / 4
zoneHalf = atr * atrMult
// ————— Storage
var box[] zones = array.new_box()
var float[] tops = array.new_float()
var float[] bots = array.new_float()
// ————— Function create zone
createZone(_top, _bot, _color, _score) =>
b = box.new(bar_index-pivotLen, _top, bar_index+extendRight, _bot,
bgcolor=color.new(_color, 85),
border_color=_color)
array.push(zones, b)
array.push(tops, _top)
array.push(bots, _bot)
if showLabels
label.new(bar_index-pivotLen, _top,
text="Score "+str.tostring(_score, format.mintick),
style=label.style_label_down,
color=_color,
textcolor=color.white,
size=size.tiny)
// ————— Resistance Zone
if not na(pivotH) and volSpike[pivotLen] and rangeSpike[pivotLen] and volScore[pivotLen] > minScore
p = priceBasis[pivotLen]
top = p + zoneHalf
bot = p - zoneHalf
createZone(top, bot, color.red, volScore[pivotLen])
// ————— Support Zone
if not na(pivotL) and volSpike[pivotLen] and rangeSpike[pivotLen] and volScore[pivotLen] > minScore
p = priceBasis[pivotLen]
top = p + zoneHalf
bot = p - zoneHalf
createZone(top, bot, color.green, volScore[pivotLen])
// ————— Zone Maintenance + Break Detection
breakBuf = atr * 0.25
for i = 0 to array.size(zones)-1
z = array.get(zones, i)
t = array.get(tops, i)
b = array.get(bots, i)
broken = close > t + breakBuf or close < b - breakBuf
if broken
box.set_border_color(z, color.gray)
box.set_bgcolor(z, color.new(color.gray, 90))
// ————— Retest Alert Logic
retest = false
for i = 0 to array.size(tops)-1
t = array.get(tops, i)
b = array.get(bots, i)
if low <= t and high >= b
retest := true
alertcondition(enableAlerts and retest, "Zone Retest", "Price retesting volume S/R zone")
Script de código aberto
Em verdadeiro espírito do TradingView, o criador deste script o tornou de código aberto, para que os traders possam revisar e verificar sua funcionalidade. Parabéns ao autor! Embora você possa usá-lo gratuitamente, lembre-se de que a republicação do código está sujeita às nossas Regras da Casa.
Aviso legal
As informações e publicações não se destinam a ser, e não constituem, conselhos ou recomendações financeiras, de investimento, comerciais ou de outro tipo fornecidos ou endossados pela TradingView. Leia mais nos Termos de Uso.
Script de código aberto
Em verdadeiro espírito do TradingView, o criador deste script o tornou de código aberto, para que os traders possam revisar e verificar sua funcionalidade. Parabéns ao autor! Embora você possa usá-lo gratuitamente, lembre-se de que a republicação do código está sujeita às nossas Regras da Casa.
Aviso legal
As informações e publicações não se destinam a ser, e não constituem, conselhos ou recomendações financeiras, de investimento, comerciais ou de outro tipo fornecidos ou endossados pela TradingView. Leia mais nos Termos de Uso.