@rekurt/openkline - v0.2.0
    Preparing search index...

    Class Ichimoku

    Ichimoku Kinkō Hyō ("one-glance equilibrium chart"). The full five-line setup, all rendered as overlays on the main price pane:

    Tenkan-sen (conversion line) = (highest(tenkan) + lowest(tenkan)) / 2 Kijun-sen (base line) = (highest(kijun) + lowest(kijun)) / 2 Senkou A (leading span A) = (Tenkan + Kijun) / 2, shifted +displacement Senkou B (leading span B) = (highest(senkouB) + lowest(senkouB)) / 2, shifted +displacement Chikou-sen (lagging span) = current close, shifted −displacement

    The kumo (cloud) is the band between Senkou A and Senkou B; we emit both as separate series and let the renderer decide whether to fill the gap.

    Standard parameters (Hosoda 1969): 9 / 26 / 52, displacement 26.

    Window highs/lows are computed via monotonic-deque so each window slide is amortized O(1) — important because Ichimoku has THREE different window sizes evaluated in parallel.

    Hierarchy (View Summary)

    Index

    Constructors

    • Parameters

      • tenkanPeriod: number = 9
      • kijunPeriod: number = 26
      • senkouBPeriod: number = 52
      • displacement: number = 26

      Returns Ichimoku

    Properties

    displacement: number = 26
    kijunPeriod: number = 26
    placement: IndicatorPlacement = 'overlay'

    Where the indicator renders (overlay vs. its own pane).

    priceScaleId?: PriceScaleSide

    Which price scale an overlay-placement indicator projects through (B2). 'right' (the default when undefined) is the primary scale shared with the price series; 'left' binds the indicator to the independent secondary scale, which the chart enables — reserving the left axis strip — only while at least one indicator requests it.

    Ignored for pane-placement indicators (they own their sub-pane axis). Subclasses opt in by overriding this getter (or declaring a matching readonly field).

    senkouBPeriod: number = 52
    tenkanPeriod: number = 9

    Accessors

    • get id(): string

      Stable human-readable identifier, e.g. sma(20) or rsi(14). Used as the cache key by the IndicatorRegistry and as a label in legends.

      Returns string

    Methods

    • Memoized wrapper around compute. Returns the same cached array reference while the SAME buffer's version and length are unchanged. The buffer identity is part of the key so reusing one indicator instance across two buffers (or swapping a chart's buffer) never returns another buffer's stale series — important right after init when distinct buffers can share version: 0 and the same length.

      When the data did change but only via a single realtime tick — an updateLast (same length) or one append (length + 1) on the SAME buffer with an unmoved head (firstTime unchanged) — and the subclass provides an updateTail hook, the tail is patched in O(tail) instead of recomputing the whole series in O(n). firstTime is part of the key precisely so a prepend/evictHead (which shifts the head and renumbers every index) can never be mistaken for an append/update and forces a full recompute.

      Use this on render paths; use compute directly to force a fresh computation.

      Parameters

      Returns IndicatorSeries[]

    • Optional incremental-update hook. When implemented, computeCached calls it instead of the full compute for the two cheap realtime mutations — an in-place updateLast (length unchanged) or a single append (length grew by one) — provided the buffer head has not moved (same firstTime).

      kind is 'updateLast' when only the final candle changed, or 'append' when exactly one candle was added.

      Contract:

      • The implementation MUST return BRAND-NEW Float64Arrays. Copy prev[k].values into a fresh array of the correct length and recompute only the affected tail. NEVER mutate the arrays inside prev: a caller may still hold a reference to the previously returned series (e.g. a renderer captured it last frame), and mutating it in place would corrupt that snapshot.
      • Return null to fall back to a full compute (e.g. when the affected index falls inside the warmup/seed region where the incremental recurrence is not valid).

      Only implement this for indicators whose tail value is a pure function of the input candles plus PREVIOUS OUTPUT values already present in prev — i.e. no hidden recursive state (Wilder smoothing, running trend flips, etc.) that an incremental step cannot reconstruct. Indicators without this hook always take the full-recompute path and stay correct automatically.

      Parameters

      Returns IndicatorSeries[] | null