דלגו לתוכן
פתיחת RaamTrade

SpinningTop — Spinning Top

תוכן זה אינו זמין עדיין בשפה שלך.

A small body with shadows on both sides: the bar moved but resolved nothing. Like the long-legged doji but with a real (if small) body, so it is more common and less emphatic.

Signature

SpinningTop(lookback, body_ratio, shadow_ratio, on=<source>)
Argument Type Required Notes
lookback int Param Yes Pinned at 1. Bounds 1–1.
body_ratio float Param or literal Yes Largest body as a fraction of the range. Default 0.3, bounds 0.05–0.6.
shadow_ratio float Param or literal Yes Minimum shadow on each side, as a fraction of the range. Default 0.2, bounds 0.05–0.5.
on= symbol No Source symbol. Defaults to the trade symbol. Reads open, high, low, close.

Formula

Body within body_ratio of the range and both shadows at least shadow_ratio of it.

Warmup

None.

Reading the value

p.value
p > 0

Pattern 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 SpinningTopFilter(Strategy):
"""Act on the pattern only in the direction of the longer trend."""
trade = Symbol()
sizing = FixedCapital()
def execute(self):
p = SpinningTop(1, 0.3, 0.2, 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="Decisive bar in an uptrend")
if self.trade.is_long and self.trade.close < sma.value:
self.sell(self.trade, self.trade.position, reason="Trend lost")

Notes

  • Returns +1 for presence; it carries no direction. Most useful as a do-not-trade filter.