Skip to content
Open RaamTrade

Engulfing

A body that completely covers the previous bar’s body while closing the other way — the strongest two-bar reversal in the vocabulary. Returns +1 bullish, −1 bearish.

Signature

Engulfing(lookback, on=<source>)
Argument Type Required Notes
lookback int Param Yes Pinned at 1; the previous bar is kept in state. Bounds 1–1.
on= symbol No Source symbol. Defaults to the trade symbol. Reads open and close.

Formula

This bar’s body spans the previous bar’s body and its colour is the opposite.

Warmup

One bar of state.

Reading the value

p.value
p > 0

Pattern indicators return a flag, not a level: +1 bullish, -1 bearish, 0 absent. They are zero on most bars by design, so treat them as event triggers rather than as something to smooth or cross.

Example

class EngulfingEntry(Strategy):
"""Act on the pattern only in the direction of the longer trend."""
trade = Symbol()
sizing = FixedCapital()
def execute(self):
p = Engulfing(1, on=self.trade)
sma = SMA(50, on=self.trade)
if p.value > 0 and self.trade.close > sma.value and self.trade.is_flat:
self.buy(self.trade, reason="Bullish engulfing")
if self.trade.is_long and self.trade.close < sma.value:
self.sell(self.trade, self.trade.position, reason="Trend lost")

Notes

  • Compares bodies, not ranges — the standard definition. OutsideBar is the range-based cousin and fires on different bars.