MorningStar — Morning Star
תוכן זה אינו זמין עדיין בשפה שלך.
A long black bar, a small gapped-down body, then a white bar closing well into the first: a three-bar bottom. The middle bar is exhaustion; the third is the reversal. Returns +1.
Signature
MorningStar(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 black; bar 2 small and entirely below bar 1’s close; bar 3 white and closing above 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 MorningStarEntry(Strategy): """Act on the pattern only in the direction of the longer trend.""" trade = Symbol() sizing = FixedCapital()
def execute(self): p = MorningStar(1, 0.5, on=self.trade) sma = SMA(50, on=self.trade) if p.value > 0 and self.trade.is_flat: self.buy(self.trade, reason="Morning star") if self.trade.is_long and self.trade.close < sma.value: self.sell(self.trade, self.trade.position, reason="Trend lost")Notes
- The three-bar reversal most traders actually watch for.
DojiStaris its two-bar precursor.