Ichimoku
Five lines plus a cloud — on its own it wants a whole screen. The leading and lagging spans are index shifts, so the cloud past the last candle isn't drawn (no future x gets invented).
Source
apps/examples/src/cases/ichimoku.ts — the real thing, type-checked in CI.
ts
import { PlotBuilder, browserDeps } from "@finchart/dom";
import type { OHLC } from "@finchart/core";
import { candleSeries, priceFormat, timeTicks } from "@finchart/core";
import { legend } from "@finchart/dom";
import { attachIchimoku } from "@finchart/indicators";
import { fixtureCandles } from "./fixture";
import { chartHost } from "./stage";
export const title = "Ichimoku";
export const description =
"Five lines plus a cloud — on its own it wants a whole screen. The leading and lagging spans are index shifts, so the cloud past the last candle isn't drawn (no future x gets invented).";
export function mount(container: HTMLElement): () => void {
const host = chartHost(container, 480);
const plot = PlotBuilder.create<OHLC>(browserDeps({ autoSize: true }))
.setSize(container.clientWidth || 900, 480)
.setAxis({
x: { ticks: timeTicks({ timeZone: "UTC", locale: "en-US" }) },
y: { position: "right", format: priceFormat({ compact: true, locale: "en-US" }) },
})
.build(host);
const price = plot.mainPane.addSeries({
series: candleSeries(),
data: fixtureCandles(),
name: "Price",
});
plot.mainPane.use(attachIchimoku({ source: price }));
plot.use(legend({}));
return Object.assign(
() => {
plot.destroy();
host.remove();
},
{ requestRender: () => plot.requestRender() },
);
}