Ichimoku Cloud
Separate Range Midpoints from Plot-Time Displacement
Install and import
npm install fintech-algorithmsimport { ichimoku } from "fintech-algorithms/technical-indicators/trend-systems/ichimoku-cloud";Signature
ichimoku(high, low, close, conversionPeriod, basePeriod, spanBPeriod, displacement)The five Ichimoku lines. Two of them are plotted shifted forward and one shifted backward, so the series a chart draws is not the series computed at that index.
Parameters
| Name | Type | Notes |
|---|---|---|
high | number[] | Per-bar high prices, chronological. |
low | number[] | Per-bar low prices, chronological. |
close | number[] | Per-bar closing prices, chronological. |
conversionPeriod | number | Lookback for the conversion line (Tenkan-sen). min: 1 · integer: true |
basePeriod | number | Lookback for the base line (Kijun-sen). min: 1 · integer: true |
spanBPeriod | number | Lookback for leading span B. min: 1 · integer: true |
displacement | number | Bars by which the leading spans are pushed forward and the lagging span pulled back. min: 1 · integer: true |
Returns
Record<string, (number | null)[]> · length same-as-input
Both the values at their origin index (span_a_origin, span_b_origin) and the displaced series a chart plots (span_a_plot, span_b_plot, lagging_plot). Using the origin series for plotting is the classic Ichimoku error.
Warm-up
The first max(conversionPeriod, basePeriod, spanBPeriod) − 1, plus the displacement on the plotted spans positions are null.
Errors
- When any period is < 1 or is not an integer — throws RangeError
- When the input series are not all the same length — throws RangeError
Complexity: time O(n × period),
space O(n).
Worked example
executed Captured by running this function on the input its own test provides. Real output of real code — but not asserted against a published figure.
Input
[113.52, 114.177204, 114.902817, 115.638854, 116.332532, 116.944154]Showing 6 of 220 elements.
[111.23, 111.374639, 111.892314, 112.558492, 113.339025, 114.174124]Showing 6 of 220 elements.
[112.42, 112.960931, 113.602175, 114.308896, 115.036356, 115.735587]Showing 6 of 220 elements.
9265226Call
ichimoku(high, low, close, conversionPeriod, basePeriod, spanBPeriod, displacement)Returns
object with 7 fields: conversion, base, span_a_origin, span_b_origin, span_a_plot, span_b_plot, lagging_plot
{
"conversion": [null, null, null, null, null, null],
"base": [null, null, null, null, null, null],
"span_a_origin": [null, null, null, null, null, null],
"span_b_origin": [null, null, null, null, null, null],
"span_a_plot": [null, null, null, null, null, null],
"span_b_plot": [null, null, null, null, null, null],
"lagging_plot": [120.589736, 120.670539, 120.683594, 120.665739, 120.660508, 120.712142]
}Diagrams
Calculation flow
Ichimoku Cloud calculation flow
flowchart LR
A["Validated finalized bar"] --> B["Causal window or recursive state"]
B --> C["Explicit seed and boundary rule"]
C --> D["Aligned Ichimoku Cloud output"]
D --> E["Diagnostics and audit evidence"]
How it works
This page states the contract — how to call it correctly. The article explains the concept: why it works, and where it breaks.
References
- Goichi Hosoda's Ichimoku Kinko Hyo — Goichi Hosoda's Ichimoku Kinko Hyo
- TradingView Ichimoku Cloud — TA-Lib project or TradingView, as identified by the linked page
- TradingView maintained Ichimoku calculation guide — TA-Lib project or TradingView
- Canonical synthetic fixture and independent arithmetic — The Fintech Builder
- R5 — TradingView Pine Script built-ins documentation — TA-Lib project or TradingView