Concept 13 / 52·Patterns·Reversal candles
‹ Donchian ChannelsFair Value Gap (FVG) ›

Engulfing Candle in Pine Script

bullish engulfing · bearish engulfing · engulfing pattern · engulfing bar · outside candle

A two-candle reversal pattern: the second candle's body opens inside the first body and closes beyond it, so one bar erases the previous bar's move in the opposite direction.

Reads best on: Liquid stocks, index futures, major FX pairs and large crypto on 1-hour to daily charts. On fast intraday charts, read the pattern only at session levels.
On this page: the Pine v6 script, checked, drawn on real NVDA bars. Backtest it free, costs charged, every trade on the chart.
01

Definition

An engulfing candle is a two-bar pattern in which the body of the second candle covers the whole body of the first, in the opposite direction. A bullish engulfing has a down candle followed by an up candle whose open is at or below the previous close and whose close is at or above the previous open. A bearish engulfing is the mirror: an up candle swallowed by a down candle. It belongs to the reversal candle family, the one- and two-bar shapes that mark a change of control at the end of a move.

The pattern works as a record of a failed continuation. In a bullish engulfing, the market opened at or below the prior close, so the downside had its chance. Then demand took price through the whole previous body and closed above where the decline had started. Anyone who went short during the first candle is under water by the close of the second. The strength of the message is in the body, not the wick. The close is where the session's argument was settled, and a close beyond the previous open shows the settlement went the other way.

The shape comes from Japanese candlestick analysis and reached Western charts through Nison's work in the early 1990s. The strict definition compares bodies only; a looser one, the outside bar, compares full ranges including wicks. There are no numeric settings in the classic rule, but traders add filters: a minimum size for the engulfing body, a preceding move for the pattern to reverse, or a trend filter so only engulfings in the direction of the larger trend are taken. The implementation here uses the body rule with equality allowed and no trend filter.

On the chart, expect engulfings to be common. On a 5-minute chart several appear every session, most inside chop where they mean little; on a daily chart after a clear leg they are rarer and worth more. Expect the pattern to be complete only at the close of the second candle, since an intrabar engulfing can shrink before the bar ends. Expect the best examples to close near the extreme of the second candle, and to come at a level that already mattered: a swing, a prior day's low, a volume-weighted line.

02

Reading the chart

Check the two bodies in order, then judge the context, because the bodies decide whether the shape exists and the context decides whether it matters.

  1. Find a candle that closed against the direction of the candle before it: an up close after a down candle for a bullish pattern, a down close after an up candle for a bearish one.
  2. Compare the bodies. For a bullish engulfing, the second open must be at or below the first close and the second close at or above the first open. Wicks are ignored in the strict rule.
  3. Wait for the second candle to close. The pattern is not complete while the bar is live, since a close that pulls back inside the previous body undoes it.
  4. Judge the size. A second body that dwarfs the first, and closes near its own extreme, shows a decisive reversal; a body that just covers a tiny previous body is a weak signal.
  5. Read the context. The pattern is a reversal shape, so it needs something to reverse: a run of candles in the first candle's direction, or a test of a level that has held before.
  6. Place the reference points. The low of the bullish pattern is the invalidation level; a close below it says the reversal has failed. The high of the bearish pattern is the mirror.
03

The maths

The pattern is a set of comparisons between the open and close of two consecutive bars.

bullisht={1Ct>Ot∧Ct−1<Ot−1∧Ct≥Ot−1∧Ot≤Ct−10otherwise\mathrm{bullish}_t = \begin{cases} 1 & C_t > O_t \land C_{t-1} < O_{t-1} \land C_t \ge O_{t-1} \land O_t \le C_{t-1} \\ 0 & \text{otherwise} \end{cases}
bearisht={1Ct<Ot∧Ct−1>Ot−1∧Ct≤Ot−1∧Ot≥Ct−10otherwise\mathrm{bearish}_t = \begin{cases} 1 & C_t < O_t \land C_{t-1} > O_{t-1} \land C_t \le O_{t-1} \land O_t \ge C_{t-1} \\ 0 & \text{otherwise} \end{cases}
bodyt=∣Ct−Ot∣\mathrm{body}_t = \lvert C_t - O_t \rvert
Ot,CtO_t, C_topen and close of bar t
Ot−1,Ct−1O_{t-1}, C_{t-1}open and close of the previous bar
bullisht,bearisht\mathrm{bullish}_t, \mathrm{bearish}_tthe pattern flags on bar t
bodyt\mathrm{body}_tthe size of the body of bar t
ttthe current bar

The rule compares bodies, so wicks do not need to be covered. An outside bar, which requires the full range to exceed the previous range, is a different and stricter shape.

Equality counts. A second candle that opens exactly at the previous close, which is normal on markets without gaps, still qualifies; a rule requiring a strictly lower open would almost never fire on continuous charts.

There is no size test in the classic rule, so an engulfing of a doji is technically valid. Many traders add a minimum body size or a comparison with the average range.

The implementation marks Long on a bullish engulfing and Short on a bearish one at the close of the second bar, on confirmed bars only, with no trend or level filter.

04

Inputs that matter

InputTypicalWhat changing it does
EngulfingonSwitches the engulfing marks on or off. With the other patterns off, the script shows engulfings alone, which is the cleanest way to study them.
Hammers and shooting starsonThe other reversal shapes in the same script. Turn them off to keep engulfing marks separate from single-bar signals.
Inside-bar breakoutsonThe continuation shape in the same script. Off is usual when studying reversals, since an inside-bar break marks a different kind of bar.
Trend filternone in the implementationAdding a filter such as the direction of a 200 EMA removes counter-trend engulfings, which are the majority of the weak ones.
05

In practice

  • As a reversal trigger at a level: a bullish engulfing on a test of the previous day's low, a swing low or an anchored VWAP is the classic entry, with the stop under the pattern low.
  • As a pullback entry in a trend: in an uptrend, an engulfing that ends a three- or four-bar pullback marks the return of buyers and puts the trade on the side of the larger move.
  • As a failure tell: a bearish engulfing right after a breakout above a range says the breakout met heavy supply, and is one of the better false-breakout tells.
  • As an exit: a bearish engulfing against an open long, especially after an extended run, is where exit rules scale out or tighten the stop even without a full reversal.
  • As a scan condition: the implementation marks each pattern at the bar close and can alert on it. The alert names the direction, not the shape, so switch the other patterns off when the alert must mean an engulfing.
  • As a higher-timeframe read: a daily or weekly engulfing carries more information than an intraday one, because more participants and more time went into the reversal.
06

Where it goes wrong

  • Trading every engulfing. Most of them occur inside ranges and reverse nothing; require a preceding move or a tested level before acting.
  • Calling the pattern before the close. An intrabar engulfing can shrink to a small body by the close; the signal exists only when the second bar is finished.
  • Ignoring the size of the first candle. Engulfing a tiny body is easy and says little; the message is stronger when the reversed candle was itself a real move.
  • Placing the stop inside the pattern. The pattern's low, or high for a bearish one, is the level that invalidates the read, and a stop inside it is likely to be hit by noise.
07

Compared with

Hammer & Shooting Star. A hammer is a single bar whose long lower wick shows a rejected low; an engulfing is two bars whose bodies show a reversed close. Both are reversal shapes, but the hammer's evidence is in the wick and the engulfing's is in the body.

Inside Bar. An inside bar is the opposite geometry: the second bar sits entirely inside the first and signals a pause that resolves on the break. An engulfing extends beyond the first body and signals a reversal on the close itself.

Break of Structure (BOS). A break of structure is a close through a confirmed swing and reads the sequence of turns; an engulfing is a close through the previous body only. An engulfing at a swing often precedes the structure break that confirms it.

Divergence. Divergence compares price with an oscillator over two swings and warns that momentum has faded. An engulfing is a price-only, two-bar event. Divergence followed by an engulfing is a common combination: the warning, then the trigger.

08

Build it in Quant

Type one of these in the Quant desk, or click it. A request that fits a checked template is assembled on the spot without a credit; anything beyond the blanks goes to the copilot, which edits on top of the checked script.

Open Engulfing Candle on the workbench chart
Drawn on real data; then audit, backtest and refine in conversation.
Open in Quant →
09

Questions

  • Does the engulfing candle have to cover the wicks?

    Not in the strict candlestick rule, which compares bodies only: the second body must cover the first body from open to close. A pattern where the whole range is covered is an outside bar, a stricter shape. The implementation uses the body rule, so a bullish engulfing needs the second open at or below the previous close and its close at or above the previous open.

  • Is a bullish engulfing enough for a long entry?

    On its own, no. It shows that demand reversed one candle's move, which happens constantly inside ranges. It carries weight when it appears where a reversal was plausible: after a clear leg down, at a level that has held before, or at the end of a pullback in an uptrend. The pattern is the trigger; the context is the reason.

  • Where does the stop go?

    Beyond the pattern's extreme. For a bullish engulfing that is below the lower of the two candles' lows, since a close under it means the buyers who produced the pattern have been overrun. For a bearish engulfing the stop goes above the higher of the two highs. Tighter stops sit inside the noise the pattern itself contains.

  • Why does the script mark so many engulfings?

    Because the pattern is common, and the script applies the body rule with no filter. On a 5-minute chart several bullish and bearish engulfings appear every session. Use a higher timeframe, or add a trend filter such as the direction of a 200 EMA, and read marks only at levels. The script is a detector, not a judgement.

  • Does the previous candle have to be the opposite colour?

    Yes, in the classic definition and in the implementation. A bullish engulfing needs a down candle first and a bearish one an up candle first, because the pattern's meaning is that one session's move was reversed. Two same-colour candles where the second is larger are a continuation, not an engulfing.

  • Which timeframe works best?

    Daily and 4-hour charts produce fewer, more meaningful patterns, since each candle summarises more trading. Intraday engulfings work on liquid markets when they are read at session levels such as the previous day's low or the opening range, and ignored elsewhere. The lower the timeframe, the more the context has to do.