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

IchimokuCloud — Ichimoku Cloud

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

Tenkan-sen (conversion), Kijun-sen (base), both Senkou spans and the lagging close — the Ichimoku set, computed at the current bar. On the chart the spans are drawn kijun_period bars ahead and the lagging close kijun_period bars behind, as on every Ichimoku chart; the values a strategy reads are not shifted — read the note below before using it.

Signature

IchimokuCloud(tenkan_period, kijun_period, senkou_period, on=<source>)
Argument Type Required Notes
tenkan_period int Param or literal Yes Conversion line. Default 9, bounds 1–200.
kijun_period int Param or literal Yes Base line. Default 26, bounds 1–400.
senkou_period int Param or literal Yes Span B lookback. Default 52, bounds 1–800.
on= symbol No Source symbol. Defaults to the trade symbol. Reads high, low and close.

Formula

$$ \text{Tenkan} = \frac{\max(H,9) + \min(L,9)}{2}, \quad \text{Kijun} = \frac{\max(H,26) + \min(L,26)}{2} $$ $$ \text{Span A} = \frac{\text{Tenkan} + \text{Kijun}}{2}, \quad \text{Span B} = \frac{\max(H,52) + \min(L,52)}{2} $$

Warmup

senkou_period bars — the longest of the three windows.

Reading the value

ich.tenkan
ich.kijun
ich.span_a
ich.span_b
ich.lagging # this bar's close (drawn kijun_period bars back)
self.trade.close > ich.span_a and self.trade.close > ich.span_b

Multi-value: cannot be chained onto or crossed.

Example

class CloudTrend(Strategy):
"""Long while price is above both spans and the conversion leads the base."""
trade = Symbol()
sizing = FixedCapital()
def execute(self):
ich = IchimokuCloud(9, 26, 52, on=self.trade)
above = self.trade.close > ich.span_a and self.trade.close > ich.span_b
if above and ich.tenkan > ich.kijun and self.trade.is_flat:
self.buy(self.trade, reason="Above the cloud")
if self.trade.close < ich.kijun and self.trade.is_long:
self.sell(self.trade, self.trade.position, reason="Lost the base line")

Notes

  • Goichi Hosoda’s Ichimoku Kinko Hyo.
  • Drawn displaced, read undisplaced. Like every Ichimoku chart, the chart draws Span A and Span B kijun_period (26) bars ahead of the bar that computed them, shading the cloud between them, and the lagging span kijun_period bars behind (offset= on the draw verbs). A strategy reads every value at the bar that computed it — ich.span_a is today’s Span A, not the one drawn above today’s candle — because you can only act on a value that exists now. To compare price with the cloud the chart shows above today’s bar, read the span from kijun_period bars ago (ich.span_a via value_at).
  • The lagging span is today’s close. ich.lagging carries no information a strategy cannot get from close; it exists so the chart can draw the Chikou line.
  • Proven by an assert-via-trade run on SPY daily (tenkan, kijun and span A matched a strategy-side reference to 1e-3 on every bar; zero alarm trades).