# Ichimoku Cloud

> Separate Range Midpoints from Plot-Time Displacement

`D07-F02-A06` · Technical Indicators → Trend Systems · archetype `series-transform` · difficulty 3/5 · verification **verified**

Full page: https://docs.thefintechbuilder.com/technical-indicators/trend-systems/ichimoku-cloud/
Agent skill: `npx skills add IslamBaraka90/Fintech-Algorithms-Library` — https://docs.thefintechbuilder.com/guides/agent-skill/

## Install and import

```bash
npm install fintech-algorithms
```

```ts
import { ichimoku } from "fintech-algorithms/technical-indicators/trend-systems/ichimoku-cloud";
```

## Signature

```ts
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 | Required | Notes |
| --- | --- | --- | --- |
| `high` | `number[]` | yes | Per-bar high prices, chronological. |
| `low` | `number[]` | yes | Per-bar low prices, chronological. |
| `close` | `number[]` | yes | Per-bar closing prices, chronological. |
| `conversionPeriod` | `number` | yes | Lookback for the conversion line (Tenkan-sen). · min: 1, integer: true |
| `basePeriod` | `number` | yes | Lookback for the base line (Kijun-sen). · min: 1, integer: true |
| `spanBPeriod` | `number` | yes | Lookback for leading span B. · min: 1, integer: true |
| `displacement` | `number` | yes | 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

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

`high`:

```json
[113.52, 114.177204, 114.902817, 115.638854, 116.332532, 116.944154]
```

Showing 6 of 220 elements.

`low`:

```json
[111.23, 111.374639, 111.892314, 112.558492, 113.339025, 114.174124]
```

Showing 6 of 220 elements.

`close`:

```json
[112.42, 112.960931, 113.602175, 114.308896, 115.036356, 115.735587]
```

Showing 6 of 220 elements.

`conversionPeriod`:

```json
9
```

`basePeriod`:

```json
26
```

`spanBPeriod`:

```json
52
```

`displacement`:

```json
26
```

### Call

```ts
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

```json
{
  "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]
}
```

## Verification and provenance

Tier: **verified** (via scenario-fixture).

The worked example below is the figure published in this algorithm's article, replayed and asserted by the test suite on every build. The arithmetic cannot drift without the build failing.

Both tiers guarantee the signature. Full explanation: https://docs.thefintechbuilder.com/guides/verification/

Generated from the docs.json payload shipped inside fintech-algorithms@0.13.1.
The signature and parameter list are checked against the compiled implementation at build time,
so a description that contradicts the code fails the build rather than reaching this file.

## Links

- Article (how it works, step by step): https://thefintechbuilder.com/technical-indicators/trend-systems/ichimoku-cloud/
- Implementation source: https://github.com/IslamBaraka90/Fintech-Algorithms-Library/blob/main/src/technical-indicators/trend-systems/ichimoku-cloud/impl.ts
- Package on npm: https://www.npmjs.com/package/fintech-algorithms
- Domain index for agents: https://docs.thefintechbuilder.com/technical-indicators/llms.txt
