PiercingLine — Piercing Line
A white bar that opens below the previous black bar’s low and closes back above the midpoint of its body: the gap down was rejected and then some. Returns +1.
Signature
PiercingLine(lookback, on=<source>)| Argument | Type | Required | Notes |
|---|---|---|---|
lookback |
int Param | Yes | Pinned at 1; the recogniser keeps the previous bar in state. Bounds 1–1. |
on= |
symbol | No | Source symbol. Defaults to the trade symbol. Reads open, high, low, close. |
Formula
Prior bar black; this bar opens below its low and closes above the midpoint of its body but below its open.
Warmup
One bar of state.
Reading the value
p.valuep > 0Pattern 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 PiercingEntry(Strategy): """Act on the pattern only in the direction of the longer trend.""" trade = Symbol() sizing = FixedCapital()
def execute(self): p = PiercingLine(1, on=self.trade) sma = SMA(50, on=self.trade) if p.value > 0 and self.trade.is_flat: self.buy(self.trade, reason="Piercing line") if self.trade.is_long and self.trade.close < sma.value: self.sell(self.trade, self.trade.position, reason="Trend lost")Notes
- The bullish mirror of
DarkCloudCover. Requires a genuine gap below the prior low, which makes it rare on liquid intraday data and more common on daily bars.