OPEN-SOURCE SCRIPT

3-Bar Compression Reversal Pattern

51
//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!")

Penafian

Maklumat dan penerbitan adalah tidak dimaksudkan untuk menjadi, dan tidak membentuk, nasihat untuk kewangan, pelaburan, perdagangan dan jenis-jenis lain atau cadangan yang dibekalkan atau disahkan oleh TradingView. Baca dengan lebih lanjut di Terma Penggunaan.