GapUp — Gap Up
תוכן זה אינו זמין עדיין בשפה שלך.
An open above the previous bar’s high: the market repriced between sessions and never traded the space in between. Returns +1.
Signature
GapUp(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{GapUp} = 1 \text{ when } O_t > H_{t-1} \text{ and } 100,\frac{O_t - H_{t-1}}{H_{t-1}} \ge \text{min percent} $$
Warmup
One bar of state.
Reading the value
gu.valuegu > 0Example
class GapContinuation(Strategy): """Trade a gap up that holds through the session.""" trade = Symbol() sizing = FixedCapital()
def execute(self): gu = GapUp(1, 0.5, on=self.trade) sma = SMA(50, on=self.trade) if gu.value > 0 and self.trade.close > self.trade.open and self.trade.is_flat: self.buy(self.trade, reason="Gap up held") if self.trade.close < sma.value and self.trade.is_long: self.sell(self.trade, self.trade.position, reason="Trend lost")Notes
- On a 24-hour session there is rarely a true gap — this is a daily-bar and cash-session tool.