GapDown — Gap Down
An open below the previous bar’s low: the market repriced downward between sessions. Returns −1.
Signature
GapDown(lookback, min_percent, on=<source>)| Argument | Type | Required | Notes |
|---|---|---|---|
lookback |
int Param | Yes | Pinned at 1. Bounds 1–1. |
min_percent |
float Param or literal | Yes | Minimum gap size in percent. 0 accepts any gap. Bounds 0.0–20.0. |
on= |
symbol | No | Source symbol. Defaults to the trade symbol. Reads open, high, low. |
Formula
$$ \text{GapDown} = -1 \text{ when } O_t < L_{t-1} \text{ and } 100,\frac{L_{t-1} - O_t}{L_{t-1}} \ge \text{min percent} $$
Warmup
One bar of state.
Reading the value
gd.valuegd < 0Example
class GapFade(Strategy): """Fade a gap down that recovers through its own open.""" trade = Symbol() sizing = FixedCapital()
def execute(self): gd = GapDown(1, 0.5, on=self.trade) sma = SMA(200, on=self.trade) if gd.value < 0 and self.trade.close > self.trade.open and self.trade.close > sma.value and self.trade.is_flat: self.buy(self.trade, reason="Gap down recovered") if self.trade.close < sma.value and self.trade.is_long: self.sell(self.trade, self.trade.position, reason="Trend lost")