지표

95종의 내장 지표를 제공합니다. id로 지표를 추가하며, 생략한 파라미터는 기본값을 사용하고 잘못된 값도 기본값으로 대체됩니다.

지표 추가

const ema = chart.addIndicator('ema', { period: 50 })          // on the price pane
const rsi = chart.addIndicator('rsi', { period: 14 }, 'bottom') // in a pane of its own
chart.updateIndicator(rsi, { period: 21 })
chart.removeIndicator(rsi)

addIndicator는 인스턴스 id를 반환합니다. 같은 지표를 여러 번 추가할 수 있으며, 각 인스턴스는 고유한 입력값, 색상, 레벨을 가집니다.

소스와 지표 위의 지표

아래 표에서 소스로 표시된 지표는 종가 대신 다른 가격 (open, high, low, hl2, hlc3, ohlc4, hlcc4)이나 다른 지표의 선을 기반으로 계산할 수 있습니다. RSI의 이동평균은 RSI 패널에 RSI의 눈금으로 그려지며, RSI를 삭제하면 함께 사라집니다.

import { indicatorSource } from '@tradecanvas/chart'

chart.updateIndicator(ema, { source: 'hlc3' })
const smoothed = chart.addIndicator('sma', { period: 9, source: indicatorSource(rsi, 'value') })

패널 지표끼리 패널을 공유할 수도 있습니다: chart.addIndicator('stochastic', {}, 'bottom', { pane: rsi }).

레벨, 색상, 값

chart.setIndicatorLevels(rsi, [20, 50, 80])   // null restores 30 / 70
chart.updateIndicatorStyle(rsi, { colors: ['#f2a93b'], lineWidths: [2] })
chart.setIndicatorVisible(rsi, false)

const series = chart.getIndicatorOutput(rsi)?.series ?? []
const latest = series[series.length - 1]?.value   // keyed by the line keys below

각 선의 최신 값은 선과 같은 색으로 축에 태그로 표시됩니다. 태그는 features.indicatorValueLabels: false 또는 setIndicatorValueLabelsVisible(false)로 끌 수 있습니다. 패널 안의 선, 레벨, 축, 십자선은 하나의 눈금을 공유합니다.

가격 패널 위 (35)

id이름기본 파라미터선
smaSimple Moving Average· 소스period: 20, source: "close"SMA
emaExponential Moving Average· 소스period: 20, source: "close"EMA
bbBollinger Bands· 소스period: 20, stdDev: 2, source: "close"Upper, Basis, Lower
vwapVolume Weighted Average Price—VWAP
ichimokuIchimoku Cloudtenkan: 9, kijun: 26, senkou: 52, displacement: 26Conversion, Base, Lead A, Lead B
psarParabolic SARstep: 0.02, max: 0.2SAR
supertrendSupertrendperiod: 10, multiplier: 3Supertrend
keltnerKeltner ChannelemaPeriod: 20, atrPeriod: 10, multiplier: 1.5Upper, Basis, Lower
donchianDonchian Channelperiod: 20Upper, Basis, Lower
pivotsPivot Points (Classic)lookback: 24R3, R2, R1, P, S1, S2, S3
avwapAnchored VWAPanchorTime: 0AVWAP
zigzagZigZagdeviation: 5Pivot
lrcLinear Regression Channel· 소스period: 100, stdDev: 2, source: "close"Upper, Basis, Lower
hmaHull Moving Average· 소스period: 21, source: "close"HMA
mtfmaMTF Moving Average· 소스period: 50, timeframe: "1d", source: "close"MA
svwapSession VWAPbands: 1VWAP, +1σ, −1σ, +2σ, −2σ, +3σ, −3σ
chandelierChandelier Exitperiod: 22, multiplier: 3Long, Short
alligatorAlligatorjaw: 13, teeth: 8, lips: 5, jawShift: 8, teethShift: 5, lipsShift: 3Jaw, Teeth, Lips
vwmaVolume Weighted Moving Average· 소스period: 20, source: "close"VWMA
wmaWeighted Moving Average· 소스period: 20, source: "close"WMA
envelopeMoving Average Envelope· 소스period: 20, percent: 2.5, source: "close"Upper, Basis, Lower
temaTriple EMA· 소스period: 20, source: "close"TEMA
volumeProfileVolume Profilerows: 24—
demaDouble Exponential Moving Average· 소스period: 20, source: "close"DEMA
smmaSmoothed Moving Average· 소스period: 14, source: "close"SMMA
almaArnaud Legoux Moving Average· 소스period: 9, offset: 0.85, sigma: 6, source: "close"ALMA
kamaKaufman Adaptive Moving Average· 소스period: 10, fast: 2, slow: 30, source: "close"KAMA
lsmaLeast Squares Moving Average· 소스period: 25, offset: 0, source: "close"LSMA
mcginleyMcGinley Dynamic· 소스period: 14, source: "close"McGinley
macrossMA Cross· 소스fast: 9, slow: 21, type: "sma", source: "close"Fast, Slow
fractalsWilliams Fractalsperiod: 2Up, Down
cksChande Kroll Stopp: 10, x: 1, q: 9Stop Long, Stop Short
sebStandard Error Bandsperiod: 21, mult: 2, smooth: 3Upper, Middle, Lower
gmmaGuppy Multiple Moving Average—EMA 3, EMA 5, EMA 8, EMA 10, EMA 12, EMA 15, EMA 30, EMA 35, EMA 40, EMA 45, EMA 50, EMA 60
maribbonMoving Average Ribbonma1: 20, ma2: 50, ma3: 100, ma4: 200, exponential: 0MA 1, MA 2, MA 3, MA 4

mtfma는 상위 시간 단위의 이동평균을 현재 차트에 표시합니다. 예를 들어 1h 봉 위에 일봉 50-MA를 그릴 수 있습니다. 완성된 상위 시간 단위 종가만 평균하므로 각 경계에서 계단식으로 바뀌며, 지나간 값이 다시 그려지지(repaint) 않습니다.

별도 패널 (60)

id이름기본 파라미터선레벨
rsiRelative Strength Index· 소스period: 14, source: "close"RSI30, 70
macdMACD· 소스fast: 12, slow: 26, signal: 9, source: "close"Histogram, MACD, Signal—
stochasticStochastic OscillatorkPeriod: 14, dPeriod: 3, smooth: 3%K, %D20, 80
atrAverage True Rangeperiod: 14ATR—
adxAverage Directional Indexperiod: 14ADX, +DI, −DI—
obvOn Balance Volume—OBV—
williamsRWilliams %Rperiod: 14%R-80, -20
cciCommodity Channel Indexperiod: 20CCI-100, 0, 100
mfiMoney Flow Indexperiod: 14MFI20, 80
aroonAroonperiod: 25Up, Down—
rocRate of Change· 소스period: 12, source: "close"ROC0
tsiTrue Strength Index· 소스longPeriod: 25, shortPeriod: 13, signalPeriod: 7, source: "close"TSI, Signal0
cmfChaikin Money Flowperiod: 20CMF—
stddevStandard Deviation· 소스period: 20, source: "close"StdDev—
adAccumulation/Distribution—A/D—
vrocVolume Rate of Changeperiod: 14VROC0
aoAwesome Oscillatorfast: 5, slow: 34AO—
chaikinOscChaikin Oscillatorfast: 3, slow: 10Chaikin—
voldeltaVolume Deltamode: 0Delta—
vortexVortex Indicatorperiod: 14VI+, VI−1
chopChoppiness Indexperiod: 14CHOP38.2, 61.8
uoUltimate Oscillatorfast: 7, mid: 14, slow: 28UO30, 70
fiForce Indexperiod: 13EFI0
crsiConnors RSI· 소스rsiPeriod: 3, streakPeriod: 2, rankPeriod: 100, source: "close"CRSI10, 90
coppockCoppock Curve· 소스longRoc: 14, shortRoc: 11, wma: 10, source: "close"Coppock0
kstKnow Sure Thing· 소스roc1: 10, roc2: 15, roc3: 20, roc4: 30, sma1: 10, sma2: 10, sma3: 10, sma4: 15, signal: 9, source: "close"KST, Signal0
elderrayElder Rayperiod: 13Bull, Bear—
stcSchaff Trend Cycle· 소스fast: 23, slow: 50, cycle: 10, source: "close"STC25, 75
kvoKlinger Oscillatorfast: 34, slow: 55, signal: 13KVO, Signal0
fisherFisher Transformperiod: 9Fisher, Trigger0
dpoDetrended Price Oscillator· 소스period: 20, source: "close"DPO—
bopBalance of Powersmooth: 14BOP0
massindexMass Indexema: 9, sum: 25Mass26.5, 27
cmoChande Momentum· 소스period: 9, source: "close"CMO-50, 0, 50
trixTRIX· 소스period: 15, signal: 9, source: "close"TRIX, Signal0
emvEase of Movementperiod: 14EOM0
pvtPrice Volume Trend—PVT—
wadWilliams A/D—WAD—
chaikinvolChaikin Volatilityema: 10, roc: 10CV0
rviRelative Vigor Indexperiod: 10RVGI, Signal0
stochrsiStochastic RSI· 소스rsiPeriod: 14, stochPeriod: 14, k: 3, d: 3, source: "close"%K, %D20, 80
ppoPercentage Price Oscillator· 소스fast: 12, slow: 26, signal: 9, source: "close"Histogram, PPO, Signal0
acAccelerator Oscillator—AC—
rmiRelative Momentum Index· 소스period: 20, momentum: 5, source: "close"RMI30, 70
disparityDisparity Index· 소스period: 14, source: "close"DI0
qstickQstickperiod: 8Qstick0
pgoPretty Good Oscillatorperiod: 14PGO-3, 0, 3
bbpbBollinger Bands %B· 소스period: 20, stdDev: 2, source: "close"%B0, 0.5, 1
bbwBollinger BandWidth· 소스period: 20, stdDev: 2, source: "close"BBW—
momMomentum· 소스period: 10, source: "close"MOM0
hvHistorical Volatility· 소스period: 10, annual: 365, source: "close"HV—
voVolume Oscillatorshort: 5, long: 10Vol Osc0
ulcerUlcer Index· 소스period: 14, source: "close"Ulcer—
smiStochastic Momentum Indexperiod: 10, smooth: 3, signal: 3SMI, Signal40, -40
rvixRelative Volatility Indexperiod: 10, smooth: 14RVI80, 50, 20
trendstrengthTrend Strength Indexperiod: 14Trend0
lrslopeLinear Regression Slopeperiod: 14Slope0
stderrorStandard Errorperiod: 14StdErr—
adrAverage Day Rangeperiod: 14ADR—
netvolumeNet Volume—Net0

voldelta(Volume Delta)는 OHLCV로 매수/매도 압력을 근사합니다. 상승 마감한 봉은 양의 거래량을, 하락 봉은 음의 거래량을 더합니다. mode: 0은 봉별 히스토그램, mode: 1은 누적 델타입니다. (진짜 틱 델타를 구하려면 체결별 매수/매도 데이터가 필요한데, OHLCV 시리즈에는 그 정보가 없습니다.)

나만의 지표

IndicatorBase를 상속하고 그릴 대상(plots), 패널 눈금, 레벨, 입력값을 선언하세요. 렌더링 코드를 직접 작성하지 않아도 차트가 지표를 그리고, 패널 눈금을 맞추고, 값을 태그로 표시하며, 위젯의 범례와 설정에 나열합니다. 사용자 지정 지표 레시피를 참고하세요.

패널: 크기 조절, 접기, 최대화, 순서 바꾸기

패널 위쪽의 구분선을 드래그해 크기를 조절합니다. ChartWidget에서는 패널마다 오른쪽 위에 버튼이 있어 패널을 위나 아래로 옮기거나, 머리글만 남게 접거나, 최대화할 수 있습니다(다른 패널은 접히고 가격 패널은 좁은 띠로 남습니다). 저장된 레이아웃에는 패널마다 크기, 순서, 접기와 최대화 상태가 유지됩니다. 코드로는 다음과 같습니다.

chart.setPanelSize(rsi, 180)        // px, clamped to a minimum
chart.setPaneCollapsed(macd, true)  // fold to its header
chart.setMaximizedPane(rsi)         // null puts the panes back
chart.movePane(rsi, -1)             // one place up; 1 = down
chart.on('paneChange', (e) => e.payload.change)  // 'collapsed' | 'maximized' | 'order' | 'scale'
chart.setPaneScale(atr, { log: true, invert: false })  // log while its values are above 0
chart.setPaneScale(atr, { percent: true })             // labels in percent of its first value on screen

ChartWidget에서 패널을 오른쪽 클릭하면 그 패널만의 로그 눈금, 반전 눈금, 퍼센트 눈금을 쓸 수 있습니다.

지표를 다른 패널로 옮기기

지표는 다른 지표의 패널에 합류하거나(그러면 그 패널의 눈금을 함께 씁니다), 자기만의 패널을 갖거나, 가격 패널로 돌아갈 수 있습니다. 자신이 주인인 패널을 떠나도 그 패널의 다른 지표는 남고(다음 패널 지표가 패널을 이어받습니다), 그 지표의 선을 읽는 지표는 함께 따라갑니다. ChartWidget에서는 범례 행의 ⋯ 버튼으로 위 패널, 아래 패널, 새 패널, 가격 패널 중에서 고를 수 있습니다.

chart.moveIndicatorToPane(cci, rsi)      // into RSI's pane
chart.moveIndicatorToPane(cci, 'new')    // a pane of its own
chart.moveIndicatorToPane(ema, 'price')  // an overlay back to the price pane
chart.canMoveIndicatorToPane(cci, rsi)   // whether it would move

실행 취소와 템플릿

지표 추가, 삭제, 편집, 이동은 그림과 같은 기록에 쌓이는 실행 취소 단계입니다 (Ctrl/⌘ Z, Ctrl/⌘ Shift Z). 실행 취소로 되살아난 지표는 원래 id 그대로 돌아오므로 그 선에 건 알림도 계속 연결됩니다. 한 지표에 잇따라 한 편집(색상 드래그, 기간 입력)은 한 단계로 묶입니다. 레이아웃을 불러오면 기록이 새로 시작됩니다.

지표 전체를 한꺼번에 꺼냈다가 다시 넣을 수 있으며, ChartWidget의 지표 템플릿이 바로 이 방식입니다. 지표 메뉴의 지표를 템플릿으로 저장…은 지표(입력값, 스타일, 레벨, 패널)를 이름을 붙여 저장하고, 템플릿을 고르면 차트의 지표가 그것으로 바뀝니다. 이 교체는 실행 취소 한 단계입니다.

const setup = chart.getIndicatorSetup()   // what a layout keeps of them
chart.applyIndicatorSetup(setup)          // in place of the chart's indicators

new ChartWidget(host, { indicatorTemplates: true })  // the default

차트 밖에서 계산하기

IndicatorWorkerHost는 Web Worker가 사용하는 것과 같은 메시지로 봉 데이터에서 지표를 계산합니다. 워커 스크립트는 아직 배포 패키지에 포함되어 있지 않으므로, null을 넘기고 플러그인을 등록해 그 자리에서 계산하세요(SSR, 테스트, 스크립트).

import { IndicatorWorkerHost, RSIIndicator } from '@tradecanvas/core'

const host = new IndicatorWorkerHost(null)
host.registerFallbackPlugin(new RSIIndicator())
const output = await host.calculate('rsi', { id: 'rsi', instanceId: 'rsi-1', params: { period: 14 } }, bars)