//@version=5 indicator("Confirmed Engulfing Breakout Pattern", overlay=true) //── Helpers bullish(c) => close[c] > open[c] bearish(c) => close[c] < open[c] //── Step 1: Identify the raw engulfing setup bearishEngulfingRaw = bullish(1) and bearish(0) and close < low[1] bullishEngulfingRaw = bearish(1) and bullish(0) and close > high[1] //── Step 2: Confirmation on the *next candle* bearishConfirmed = bearishEngulfingRaw[1] and close < low[1] bullishConfirmed = bullishEngulfingRaw[1] and close > high[1] //── Step 3: Plot arrows on the engulfing candle (1 bar back) plotshape(bearishConfirmed, title="Confirmed Bearish Engulfing", style=shape.triangledown, location=location.abovebar, color=color.red, size=size.small, offset=-1) plotshape(bullishConfirmed, title="Confirmed Bullish Engulfing", style=shape.triangleup, location=location.belowbar, color=color.green, size=size.small, offset=-1) //── Alerts alertcondition(bearishConfirmed, title="Bearish Engulfing Confirmed Alert", message="Bearish engulfing breakdown confirmed") alertcondition(bullishConfirmed, title="Bullish Engulfing Confirmed Alert", message="Bullish engulfing breakout confirmed")