Intraday S/R Breaks (Clean)

indicator("Intraday S/R Breaks (Clean)", overlay=true)
length = input.int(6, title="Volume MA Period")
showLines = input.bool(true, title="Show S/R Lines?")
showZones = input.bool(false, title="Show Zones?")
// Volume logic
volMA = ta.sma(volume, length)
// Fractal logic (basic 5-bar high/low with volume filter)
isFractalUp = high[2] > high[3] and high[2] > high[1] and high[3] > high[4] and high[1] > high[0] and volume[2] > volMA[2]
isFractalDown = low[2] < low[3] and low[2] < low[1] and low[3] < low[4] and low[1] < low[0] and volume[2] > volMA[2]
var float resistance = na
var float support = na
if isFractalUp
resistance := high[2]
if isFractalDown
support := low[2]
// Plot lines/zones
resLine = showLines and not na(resistance) ? line.new(x1=bar_index[2], y1=resistance, x2=bar_index, y2=resistance, extend=extend.right, color=color.red, width=1) : na
supLine = showLines and not na(support) ? line.new(x1=bar_index[2], y1=support, x2=bar_index, y2=support, extend=extend.right, color=color.green, width=1) : na
// Alerts
resBreak = ta.crossover(close, resistance)
supBreak = ta.crossunder(close, support)
alertcondition(resBreak, title="Resistance Break", message="Resistance Break!")
alertcondition(supBreak, title="Support Break", message="Support Break!")
if resBreak
label.new(bar_index, high, "📈 RESISTANCE BROKEN", style=label.style_label_down, color=color.red, textcolor=color.white)
if supBreak
label.new(bar_index, low, "📉 SUPPORT BROKEN", style=label.style_label_up, color=color.green, textcolor=color.white)
Skrip sumber terbuka
Dalam semangat sebenar TradingView, pencipta skrip ini telah menjadikannya sumber terbuka supaya pedagang dapat menilai dan mengesahkan kefungsiannya. Terima kasih kepada penulis! Walaupun anda boleh menggunakannya secara percuma, ingat bahawa menerbitkan semula kod ini adalah tertakluk kepada Peraturan Dalaman kami.
Untuk akses pantas pada carta, tambah skrip ini kepada kegemaran anda — ketahui lebih lanjut di sini.
Penafian
Skrip sumber terbuka
Dalam semangat sebenar TradingView, pencipta skrip ini telah menjadikannya sumber terbuka supaya pedagang dapat menilai dan mengesahkan kefungsiannya. Terima kasih kepada penulis! Walaupun anda boleh menggunakannya secara percuma, ingat bahawa menerbitkan semula kod ini adalah tertakluk kepada Peraturan Dalaman kami.
Untuk akses pantas pada carta, tambah skrip ini kepada kegemaran anda — ketahui lebih lanjut di sini.