indicator · on price · open source

Mitigated Order Blocks indicator

Mitigated Order Blocks is a free open-source indicator. Mitigated Order Blocks — bullish OBs coloured grey once price trades back through them… Deepwick Script runs a subset of Pine Script.

v1Updated 3 Oct 2026▲ 0 users
Running…
Loading chart…

What Mitigated Order Blocks does

Mitigated Order Blocks — bullish OBs coloured grey once price trades back through them, signalling the zone has been 'mitigated' (used up).

  • Top/bottom lines drawn for extendBars after formation.
  • Green = live OB, grey = mitigated OB.
  • Use mitigated OBs as historical reference points for back-testing setups.
  • Mitigation = the OB has paid out; treat mitigated OBs as neutral levels.
  • A mitigated OB often becomes support/resistance on the other side of the chart.
  • Default extendBars of 50 is generous; lower it to 20 for tighter historical context.
  • The mitigated-state colour flips the moment a bar trades back through the OB bottom — instant feedback.
  • Use both bullish and bearish colour inputs to theme active and mitigated states distinctly.

Source code

Deepwick Script, a subset of Pine Script · read-only

//@version=6
indicator("Mitigated Order Blocks", 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(50, "Extend Bars", minval=5, maxval=200)
activeColor = input.string("color.green", "Active OB Color")
mitigatedColor = input.string("color.gray", "Mitigated OB Color")
alertMitigated = input.bool(true, "Alert on Mitigation")
alertNew = input.bool(false, "Alert on New OB")
transparency = input.int(85, "Fill Transparency", minval=50, maxval=99)
markerText = input.string("BOB", "Marker Text")
markerColor = input.string("color.yellow", "Marker Color")
lineWidth = input.int(2, "Line Width", minval=1, maxval=5)
ph = ta.pivothigh(high, swing, swing)
var float lastPh = na
var float prevPh = na
var float obTop = na
var float obBot = na
var int obAge = 9999
var bool mitigated = false
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]
            obTop := high[i]
            obBot := low[i]
            obAge := 0
            mitigated := false
            found := true
            break
obAge += 1
mit = not na(obTop) and low <= obBot
mitigated := mitigated or mit
obTop := obAge > extendBars ? na : obTop
obBot := obAge > extendBars ? na : obBot
p_OB_Top_Live = plot(mitigated ? na : obTop, "OB Top Live", color=activeColor, style=plot.style_linebr)
p_OB_Bot_Live = plot(mitigated ? na : obBot, "OB Bot Live", color=activeColor, style=plot.style_linebr)
p_OB_Top_Mitigated = plot(mitigated ? obTop : na, "OB Top Mitigated", color=mitigatedColor, style=plot.style_linebr)
p_OB_Bot_Mitigated = plot(mitigated ? obBot : na, "OB Bot Mitigated", color=mitigatedColor, style=plot.style_linebr)
fill(p_OB_Top_Live, p_OB_Bot_Live, color=color.new(activeColor, 85))
fill(p_OB_Top_Mitigated, p_OB_Bot_Mitigated, color=color.new(mitigatedColor, 90))
alertcondition(mit and not mitigated[1], "OB mitigated", "Order block has been mitigated")
alertcondition(not na(obTop) and na(obTop[1]), "New bullish OB", "New bullish OB formed")
alertcondition(low <= obBot and close > obTop and not mitigated[1], "OB fully mitigated", "OB has been fully mitigated by price action")

Comments

No comments yet.

Sign in to comment.