Appearance
Ichimoku Cloud
Conversion and base lines, a lagging span and the cloud projected 26 bars ahead.
Kind indicator · Drawn on the price pane
Try it
On the chart, press / and choose Ichimoku Cloud under Trend. To change it, copy the source below into the AlphaScript editor.
Inputs
| Input | Type | Default |
|---|---|---|
| Conversion line length | int | 9 |
| Base line length | int | 26 |
| Leading span B length | int | 52 |
| Lagging span | int | 26 |
| Conversion line color | color | "#2962FF" |
| Base line color | color | "#B71C1C" |
| Lagging span color | color | "#43A047" |
| Leading span A color | color | "#A5D6A7" |
| Leading span B color | color | "#EF9A9A" |
| Cloud up color | color | "rgba(67,160,71,0.1)" |
| Cloud down color | color | "rgba(244,67,54,0.1)" |
Source
From packages/alphascript/indicators/ichimoku.as.js.
js
indicator({ name: "Ichimoku Cloud", shortTitle: "Ichimoku", overlay: true });
const conversionPeriods = input.int("Conversion line length", 9, { min: 1 });
const basePeriods = input.int("Base line length", 26, { min: 1 });
const spanBPeriods = input.int("Leading span B length", 52, { min: 1 });
const displacement = input.int("Lagging span", 26, { min: 1, max: 500 });
/** @param {number} n */
const donchian = (n) => ta.calc([ta.lowest(candle.low, n), ta.highest(candle.high, n)], (l, h) => (l + h) / 2);
const conversion = donchian(conversionPeriods), base = donchian(basePeriods);
const leadA = ta.calc([conversion, base], (a, b) => (a + b) / 2), leadB = donchian(spanBPeriods);
plot(conversion, { title: "Conversion Line", color: input.color("Conversion line color", "#2962FF", { group: "Style" }) });
plot(base, { title: "Base Line", color: input.color("Base line color", "#B71C1C", { group: "Style" }) });
plot(candle.close, { title: "Lagging Span", offset: 1 - displacement, color: input.color("Lagging span color", "#43A047", { group: "Style" }) });
plot(leadA, { title: "Leading Span A", offset: displacement - 1, color: input.color("Leading span A color", "#A5D6A7", { group: "Style" }) });
plot(leadB, { title: "Leading Span B", offset: displacement - 1, color: input.color("Leading span B color", "#EF9A9A", { group: "Style" }) });
fill(leadA, leadB, { title: "Cloud", offset: displacement - 1, color: input.color("Cloud up color", "rgba(67,160,71,0.1)", { group: "Style" }),
colorDown: input.color("Cloud down color", "rgba(244,67,54,0.1)", { group: "Style" }) });