EveningStar — Evening Star
A long white bar, a small gapped-up body, then a black bar closing well into the first: a three-bar top. Returns −1.
Signature
EveningStar(lookback, star_ratio, on=<source>)| Argument | Type | Required | Notes |
|---|---|---|---|
lookback |
int Param | Yes | Pinned at 1; three bars are kept in state. Bounds 1–1. |
star_ratio |
float Param or literal | Yes | Largest middle body, as a fraction of the first. Default 0.5, bounds 0.1–1.0. |
on= |
symbol | No | Source symbol. Defaults to the trade symbol. Reads open and close. |
Formula
Bar 1 white; bar 2 small and entirely above bar 1’s close; bar 3 black and closing below the midpoint of bar 1’s body.
Warmup
Three bars 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 EveningStarExit(Strategy): """Act on the pattern only in the direction of the longer trend.""" trade = Symbol() sizing = FixedCapital()
def execute(self): p = EveningStar(1, 0.5, 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="No topping pattern") if p.value < 0 and self.trade.is_long: self.sell(self.trade, self.trade.position, reason="Evening star")Notes
- The bearish mirror of
MorningStar.