indicator · on price · open source
Order Blocks (Bullish)
Running…
Loading chart…
About
Bullish Order Blocks mark the last bearish candle before a bullish break of structure — institutions typically entered long there, and price tends to retest the zone.
- Green zone = OB top/bottom; shaded fill shows the mitigation range.
- Zones extend for
extendBarsbars, then expire if price never returned. - Combine with a discount filter (below 50% of recent range) for highest-probability longs.
Source code
//@version=5
indicator("Order Blocks (Bullish)", overlay=true)
swing = input.int(5, "Swing Length", minval=2, maxval=50)
lookback = input.int(30, "OB Lookback", minval=5, maxval=100)
extendBars = input.int(30, "Extend Bars", minval=5, maxval=200)
ph = ta.pivothigh(high, swing, swing)
var float lastPh = na
var float prevPh = na
var float obBullTop = na
var float obBullBot = na
var int obBullAge = 9999
if not na(ph)
prevPh := lastPh
lastPh := ph
if not na(lastPh) and not na(prevPh) and lastPh > prevPh
found = false
for i = 1 to math.min(lookback, swing * 4)
if not found and close[i] < open[i]
obBullTop := high[i]
obBullBot := low[i]
obBullAge := 0
found := true
break
obBullAge += 1
if obBullAge > extendBars
obBullTop := na
obBullBot := na
p_Bull_OB_Top = plot(obBullTop, "Bull OB Top", color=color.green, style=plot.style_linebr)
p_Bull_OB_Bot = plot(obBullBot, "Bull OB Bot", color=color.green, style=plot.style_linebr)
fill(p_Bull_OB_Top, p_Bull_OB_Bot, color=color.new(color.green, 85))
alertcondition(not na(obBullTop) and na(obBullTop[1]), "New bullish OB", "Bullish order block formed")
No comments yet.
Sign in to comment.