All indicators
Trend / Price pane

Ichimoku Cloud

Ichimoku Kinko Hyo: conversion and base lines, a cloud of two leading spans projected into the future, and the lagging close.

  • Ichimoku
  • Built into Spectral
  • Updates every tick
  • ichimoku
  • kumo
  • cloud
  • tenkan
  • kijun
  • senkou span
  • chikou
  • support resistance

By Spectral · v1.0.0

MIT-0: free to use, change and share, no attribution needed. What you build from it is yours.

Already in Spectral: add it from the Indicators toolbox. The file here is the same indicator written as a custom indicator, to change or learn from. Installed, it appears next to the built-in one, marked Custom.

Ichimoku Cloud on a Spectral chart
Spectral chart with sample market data, default settings.

Overview

Ichimoku Kinko Hyo (one-glance equilibrium chart) by Goichi Hosoda. The conversion line (Tenkan-sen) and the base line (Kijun-sen) are the middle of the highest high and lowest low over 9 and 26 bars. Leading span A (Senkou Span A) is the average of those two lines and leading span B (Senkou Span B) the middle of the 52-bar range; both are projected 26 bars forward, counting the current bar as the first (25 bars past it), and the area between them is the cloud (Kumo). The lagging span (Chikou Span) is the close drawn back the same way.

Because the spans are projected forward, the cloud continues into the empty space right of the last bar and shows where support or resistance will sit in the coming bars.

How to read it

Price above the cloud is bullish, below it bearish, inside it undecided. A green cloud (span A above span B) leans up, a red cloud leans down, and a thick cloud is stronger support or resistance than a thin one; a twist of the spans ahead of price warns of a possible change of trend.

The conversion line crossing above the base line is a bullish signal (Tenkan/Kijun cross), stronger above the cloud; the reverse is bearish. The base line acts as a level price often returns to. The lagging span above the price it is drawn against confirms an uptrend, below it a downtrend.

Settings and limitations

The lengths 9, 26 and 52 and the displacement of 26 are Hosoda's originals for a six-day trading week; the preset 20, 60, 120 and 30 is a common choice for markets that trade around the clock. The displacement only moves the spans and does not change their values. The cloud needs Leading span B length bars before it appears.

Notes

Matches TradingView's Ichimoku Cloud: the displacement counts the current bar as the first, so with 26 the cloud reaches 25 bars past the last bar and the lagging span sits 25 bars back, and the cloud is green where span A is above span B and red elsewhere.

Settings

Each setting appears in the indicator's settings panel in Spectral, next to a color setting for every output.

SettingTypeDefaultRange or optionsWhat it does
Conversion line lengthWhole number91 – 500Bars in the conversion line (Tenkan-sen), the middle of their highest high and lowest low.
Base line lengthWhole number261 – 500Bars in the base line (Kijun-sen), the middle of their highest high and lowest low.
Leading span B lengthWhole number521 – 500Bars in leading span B (Senkou Span B), the middle of their highest high and lowest low.
DisplacementWhole number261 – 250How far the cloud is projected forward and the lagging span drawn back, counting the current bar as the first, as on TradingView.

Presets

Each preset is its own entry in the Indicators toolbox, with these settings changed.

Toolbox entryShort nameSettings
Ichimoku Cloud (20, 60, 120, 30)Ichimoku 20Conversion line length: 20Base line length: 60Leading span B length: 120Displacement: 30

What it draws

Lines

  • Conversion linesolid · 1 px#2962FF
  • Base linesolid · 1.5 px · primary#B71C1C
  • Lagging spansolid · 1 px#43A047
  • Leading span Asolid · 1 px#A5D6A7
  • Leading span Bsolid · 1 px#EF9A9A

Zones

  • Cloud, span A above Bfilled at 20% opacity#43A047
  • Cloud, span B above Afilled at 20% opacity#E53935

Source

Save it as ichimoku-cloud.js and add it with Indicators → Custom indicators → Add file…. The format is explained in the custom indicators guide.

// Copyright (c) 2026 Spectral
// SPDX-License-Identifier: MIT-0
// Free to use, copy, modify and share: https://spectral.trade/docs/custom-indicators/LICENSE.txt
/** @type {import('./spectral-indicator').IndicatorV2} */
export default {
  schemaVersion: 2,
  id: 'ichimoku-cloud',
  name: 'Ichimoku Cloud',
  shortName: 'Ichimoku',
  version: '1.0.0',
  author: 'Spectral',
  description: 'Ichimoku Kinko Hyo: conversion and base lines, a cloud of two leading spans projected into the future, and the lagging close.',
  pane: 'price',
  live: { lookback: 'conversionLength + baseLength + spanBLength' },
  inputs: {
    conversionLength: { type: 'integer', label: 'Conversion line length', default: 9, min: 1, max: 500, description: 'Bars in the conversion line (Tenkan-sen), the middle of their highest high and lowest low.' },
    baseLength: { type: 'integer', label: 'Base line length', default: 26, min: 1, max: 500, description: 'Bars in the base line (Kijun-sen), the middle of their highest high and lowest low.' },
    spanBLength: { type: 'integer', label: 'Leading span B length', default: 52, min: 1, max: 500, description: 'Bars in leading span B (Senkou Span B), the middle of their highest high and lowest low.' },
    displacement: { type: 'integer', label: 'Displacement', default: 26, min: 1, max: 250, description: 'How far the cloud is projected forward and the lagging span drawn back, counting the current bar as the first, as on TradingView.' },
  },
  plots: {
    conversion: { label: 'Conversion line', color: '#2962FF', lineWidth: 1 },
    base: { label: 'Base line', color: '#B71C1C', lineWidth: 1.5, primary: true },
    lagging: { label: 'Lagging span', color: '#43A047', lineWidth: 1, offset: '-displacement+1' },
    spanA: { label: 'Leading span A', color: '#A5D6A7', lineWidth: 1, offset: 'displacement-1' },
    spanB: { label: 'Leading span B', color: '#EF9A9A', lineWidth: 1, offset: 'displacement-1' },
  },
  zones: {
    bullCloud: { label: 'Cloud, span A above B', color: '#43A047', opacity: 0.2, offset: 'displacement-1' },
    bearCloud: { label: 'Cloud, span B above A', color: '#E53935', opacity: 0.2, offset: 'displacement-1' },
  },
  presets: [
    { id: 'crypto', name: 'Ichimoku Cloud (20, 60, 120, 30)', shortName: 'Ichimoku 20', inputs: { conversionLength: 20, baseLength: 60, spanBLength: 120, displacement: 30 } },
  ],
  docs: {
    overview: 'Ichimoku Kinko Hyo (one-glance equilibrium chart) by Goichi Hosoda. The conversion line (Tenkan-sen) and the base line (Kijun-sen) are the middle of the highest high and lowest low over 9 and 26 bars. Leading span A (Senkou Span A) is the average of those two lines and leading span B (Senkou Span B) the middle of the 52-bar range; both are projected 26 bars forward, counting the current bar as the first (25 bars past it), and the area between them is the cloud (Kumo). The lagging span (Chikou Span) is the close drawn back the same way.\n\nBecause the spans are projected forward, the cloud continues into the empty space right of the last bar and shows where support or resistance will sit in the coming bars.',
    howToRead: 'Price above the cloud is bullish, below it bearish, inside it undecided. A green cloud (span A above span B) leans up, a red cloud leans down, and a thick cloud is stronger support or resistance than a thin one; a twist of the spans ahead of price warns of a possible change of trend.\n\nThe conversion line crossing above the base line is a bullish signal (Tenkan/Kijun cross), stronger above the cloud; the reverse is bearish. The base line acts as a level price often returns to. The lagging span above the price it is drawn against confirms an uptrend, below it a downtrend.',
    settings: 'The lengths 9, 26 and 52 and the displacement of 26 are Hosoda\'s originals for a six-day trading week; the preset 20, 60, 120 and 30 is a common choice for markets that trade around the clock. The displacement only moves the spans and does not change their values. The cloud needs Leading span B length bars before it appears.',
    notes: 'Matches TradingView\'s Ichimoku Cloud: the displacement counts the current bar as the first, so with 26 the cloud reaches 25 bars past the last bar and the lagging span sits 25 bars back, and the cloud is green where span A is above span B and red elsewhere.',
  },
  calculate(ctx) {
    const { bars, inputs, ta } = ctx;
    const highs = ta.source(bars, 'high');
    const lows = ta.source(bars, 'low');
    const midpoint = (length) => {
      const highest = ta.highest(highs, length);
      const lowest = ta.lowest(lows, length);
      return highest.map((high, index) => (high === null || lowest[index] === null ? null : (high + lowest[index]) / 2));
    };
    const conversion = midpoint(inputs.conversionLength);
    const base = midpoint(inputs.baseLength);
    const spanA = conversion.map((value, index) => (value === null || base[index] === null ? null : (value + base[index]) / 2));
    const spanB = midpoint(inputs.spanBLength);
    // Each cloud color runs one bar past a twist of the spans, so the two colors meet without a gap.
    const bullish = spanA.map((value, index) => value !== null && spanB[index] !== null && value > spanB[index]);
    const cloud = (wanted) => {
      const upper = new Array(bars.length).fill(null);
      const lower = new Array(bars.length).fill(null);
      for (let index = 0; index < bars.length; index += 1) {
        if (spanA[index] === null || spanB[index] === null) continue;
        const previous = index > 0 && spanA[index - 1] !== null && spanB[index - 1] !== null ? bullish[index - 1] : bullish[index];
        if (bullish[index] !== wanted && previous !== wanted) continue;
        upper[index] = spanA[index];
        lower[index] = spanB[index];
      }
      return { upper, lower };
    };
    return {
      plots: { conversion, base, lagging: ta.source(bars, 'close'), spanA, spanB },
      zones: { bullCloud: cloud(true), bearCloud: cloud(false) },
    };
  },
};

Adapt it with an LLM

Paste this into your assistant and replace the second-to-last line with the change you want.

Start from this Spectral custom indicator: https://spectral.trade/indicators/ichimoku-cloud.js
Format reference: https://spectral.trade/docs/custom-indicators.llm.md
Keep the file format and every rule of the reference; give the result a new id, name, shortName and version, and update docs and input descriptions to match.
Keep its live updates exact and fast (section "Fast live updates" of the reference): carry values from bar to bar only through ctx.ta, and raise live.lookback if the change reads further back; Spectral rejects a file whose live updates differ from a full recalculation or are too slow.
Change I want: <describe the change>
Answer with the complete file in one code block, ready to save as <id>.js.