Downloading...
OPEN-SOURCE SCRIPT

3-Bar Compression Reversal Pattern

20
//version=5
indicator("3-Bar Compression Reversal Pattern", overlay=true)

// Get candle OHLCs
open1 = open[2]
close1 = close[2]
body1 = math.abs(close1 - open1)

open2 = open[1]
close2 = close[1]
body2 = math.abs(close2 - open2)

// 2nd candle body < 50% of 1st
secondSmall = body2 < (0.5 * body1)

// 3rd candle engulfs both 1st and 2nd
lowAll = math.min(low[2], low[1])
highAll = math.max(high[2], high[1])
engulfAll = (high > highAll) and (low < lowAll)

// Final condition
patternDetected = secondSmall and engulfAll

// Plot signal
plotshape(patternDetected, location=location.belowbar, color=color.green, style=shape.labelup, size=size.small, title="Pattern Signal")
alertcondition(patternDetected, title="3-Bar Reversal Alert", message="3-Bar Compression Reversal Pattern Detected!")

Disclaimer

The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.