Pivot Points — 기간은 소비자의 지식
직전 기간의 고·저·종으로 이번 기간의 축(P)과 저항(R)·지지(S)를 긋는다 — 기간의 경계는 anchor 술어로 소비자가 말한다(코어에 세션 개념이 없다, VWAP과 같은 계약). 이 데모는 1분봉 위에 매시 정각을 경계로 잡았다. 기간 첫 봉의 구멍이 수평 선분들을 서로 끊는다.
소스
apps/examples/src/cases/pivots.ts — 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 { attachPivotPoints } from "@finchart/indicators";
import { fixtureCandles } from "./fixture";
import { chartHost } from "./stage";
export const title = "Pivot Points — 기간은 소비자의 지식";
export const description =
"직전 기간의 고·저·종으로 이번 기간의 축(P)과 저항(R)·지지(S)를 긋는다 — 기간의 경계는 anchor 술어로 소비자가 말한다(코어에 세션 개념이 없다, VWAP과 같은 계약). " +
"이 데모는 1분봉 위에 매시 정각을 경계로 잡았다. 기간 첫 봉의 구멍이 수평 선분들을 서로 끊는다.";
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: "ko" }) },
y: { position: "right", format: priceFormat({ compact: true, locale: "ko" }) },
})
.build(host);
const price = plot.mainPane.addSeries({
series: candleSeries(),
data: fixtureCandles(),
name: "가격",
});
plot.mainPane.use(
attachPivotPoints({
source: price,
// 시간 축의 의미는 여기(소비자)의 지식이다 — 매시 정각이 새 기간.
// x는 타입부터 숫자다 (ADR-0040) — 변환 없이 그대로 센다.
anchor: (candle) => candle.x % 3_600_000 === 0,
depth: 2,
}),
);
plot.use(legend({}));
return Object.assign(
() => {
plot.destroy();
host.remove();
},
{ requestRender: () => plot.requestRender() },
);
}