Code Library / Candlestick Patterns

Pine Script Engulfing Pattern

Detect bullish and bearish engulfing patterns.

Language: Pine Script · Category: Candlestick Patterns · Tags: engulfing, candlestick, Pine Script, pattern, reversal

Source code

//@version=5
indicator("Engulfing",overlay=true)
bull=close[1]<open[1] and close>open and open<=close[1] and close>=open[1]
bear=close[1]>open[1] and close<open and open>=close[1] and close<=open[1]
plotshape(bull,"Bull",shape.triangleup,location.belowbar,color.green)
plotshape(bear,"Bear",shape.triangledown,location.abovebar,color.red)

How to use this snippet

This is a building block, not a finished trading system. Paste it into your own Pine Script project, compile it, and test it on a demo account with your broker's real spreads before relying on it. You can convert it to MQL4 or MQL5 with the Pine Script converter.

Related snippets