หน้านี้ยังไม่ได้แปลเป็นภาษาไทย จึงแสดงเป็นภาษาอังกฤษ

Indicators

95 built-in indicators. Add one by its id; parameters you leave out take their defaults, and invalid ones fall back to them.

Adding an indicator

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 returns an instance id: the same indicator can be added several times, each instance with its own inputs, colours and levels.

Sources and indicators on indicators

Indicators marked source below can run on another price than the close (open, high, low, hl2, hlc3, ohlc4, hlcc4) or on another indicator's line. A moving average of RSI is drawn in RSI's pane, on its scale, and goes when RSI does.

import { indicatorSource } from '@tradecanvas/chart'

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

Pane indicators can also share a pane: chart.addIndicator('stochastic', {}, 'bottom', { pane: rsi }).

Levels, colours and values

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

Each line's latest value is tagged on its axis in the line's colour; turn the tags off with features.indicatorValueLabels: false or setIndicatorValueLabelsVisible(false). A pane's lines, levels, axis and crosshair share one scale.

On the price pane (35)

idNameDefault paramsLines
smaSimple Moving Average· sourceperiod: 20, source: "close"SMA
emaExponential Moving Average· sourceperiod: 20, source: "close"EMA
bbBollinger Bands· sourceperiod: 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· sourceperiod: 100, stdDev: 2, source: "close"Upper, Basis, Lower
hmaHull Moving Average· sourceperiod: 21, source: "close"HMA
mtfmaMTF Moving Average· sourceperiod: 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· sourceperiod: 20, source: "close"VWMA
wmaWeighted Moving Average· sourceperiod: 20, source: "close"WMA
envelopeMoving Average Envelope· sourceperiod: 20, percent: 2.5, source: "close"Upper, Basis, Lower
temaTriple EMA· sourceperiod: 20, source: "close"TEMA
volumeProfileVolume Profilerows: 24—
demaDouble Exponential Moving Average· sourceperiod: 20, source: "close"DEMA
smmaSmoothed Moving Average· sourceperiod: 14, source: "close"SMMA
almaArnaud Legoux Moving Average· sourceperiod: 9, offset: 0.85, sigma: 6, source: "close"ALMA
kamaKaufman Adaptive Moving Average· sourceperiod: 10, fast: 2, slow: 30, source: "close"KAMA
lsmaLeast Squares Moving Average· sourceperiod: 25, offset: 0, source: "close"LSMA
mcginleyMcGinley Dynamic· sourceperiod: 14, source: "close"McGinley
macrossMA Cross· sourcefast: 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 plots a moving average from a higher timeframe on the current chart — the daily 50-MA on 1h bars, say. It averages only completed higher-timeframe closes, so it steps at each boundary and never repaints.

In a pane of their own (60)

idNameDefault paramsLinesLevels
rsiRelative Strength Index· sourceperiod: 14, source: "close"RSI30, 70
macdMACD· sourcefast: 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· sourceperiod: 12, source: "close"ROC0
tsiTrue Strength Index· sourcelongPeriod: 25, shortPeriod: 13, signalPeriod: 7, source: "close"TSI, Signal0
cmfChaikin Money Flowperiod: 20CMF—
stddevStandard Deviation· sourceperiod: 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· sourcersiPeriod: 3, streakPeriod: 2, rankPeriod: 100, source: "close"CRSI10, 90
coppockCoppock Curve· sourcelongRoc: 14, shortRoc: 11, wma: 10, source: "close"Coppock0
kstKnow Sure Thing· sourceroc1: 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· sourcefast: 23, slow: 50, cycle: 10, source: "close"STC25, 75
kvoKlinger Oscillatorfast: 34, slow: 55, signal: 13KVO, Signal0
fisherFisher Transformperiod: 9Fisher, Trigger0
dpoDetrended Price Oscillator· sourceperiod: 20, source: "close"DPO—
bopBalance of Powersmooth: 14BOP0
massindexMass Indexema: 9, sum: 25Mass26.5, 27
cmoChande Momentum· sourceperiod: 9, source: "close"CMO-50, 0, 50
trixTRIX· sourceperiod: 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· sourcersiPeriod: 14, stochPeriod: 14, k: 3, d: 3, source: "close"%K, %D20, 80
ppoPercentage Price Oscillator· sourcefast: 12, slow: 26, signal: 9, source: "close"Histogram, PPO, Signal0
acAccelerator Oscillator—AC—
rmiRelative Momentum Index· sourceperiod: 20, momentum: 5, source: "close"RMI30, 70
disparityDisparity Index· sourceperiod: 14, source: "close"DI0
qstickQstickperiod: 8Qstick0
pgoPretty Good Oscillatorperiod: 14PGO-3, 0, 3
bbpbBollinger Bands %B· sourceperiod: 20, stdDev: 2, source: "close"%B0, 0.5, 1
bbwBollinger BandWidth· sourceperiod: 20, stdDev: 2, source: "close"BBW—
momMomentum· sourceperiod: 10, source: "close"MOM0
hvHistorical Volatility· sourceperiod: 10, annual: 365, source: "close"HV—
voVolume Oscillatorshort: 5, long: 10Vol Osc0
ulcerUlcer Index· sourceperiod: 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) approximates buy/sell pressure from OHLCV — bars closing up add positive volume, down bars negative. mode: 0 is the per-bar histogram, mode: 1 cumulative delta. (A true tick delta needs per-trade bid/ask data, which an OHLCV series doesn't carry.)

Your own indicator

Extend IndicatorBase and declare what it draws (plots), its pane scale, levels and inputs; the chart draws it, scales its pane, tags its values and lists it in the widget's legend and settings without rendering code of yours. See the custom indicator recipe.

Panes: resize, fold, maximise, reorder

Drag the divider above a pane to resize it. In ChartWidget each pane has buttons at its top right: move it up or down, fold it to its header, maximise it (the other panes fold and the price pane keeps a strip). Saved layouts keep each pane's size, order, fold and maximise. The same from code:

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

Right-click a pane in ChartWidget for its own logarithmic, inverted or percent scale.

Moving an indicator to another pane

An indicator can join another indicator's pane (it then shares that pane's scale), take a pane of its own, or go back to the price pane. When it leaves a pane it owned, the others in it stay (the next pane indicator takes the pane over), and those reading its lines follow it. In ChartWidget, the ⋯ button on a legend row offers the pane above, the pane below, a new pane and the price pane.

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

Undo, and templates

Adding, removing, editing and moving indicators are undo steps in the same history as drawings (Ctrl/⌘ Z, Ctrl/⌘ Shift Z); an undone indicator comes back under its own id, so alerts on its lines still match. A burst of edits to one indicator (a colour dragged, a period typed) is one step. A loaded layout starts a fresh history.

The indicators can be taken and put back as a whole, which is what ChartWidget's indicator templates do: Save indicators as template… in the indicators menu keeps them (inputs, style, levels, panes) under a name, and picking a template puts them in place of the chart's, as one undo step.

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

Computing outside the chart

IndicatorWorkerHost computes an indicator from bars with the same messages a Web Worker would use. The worker script is not part of the published packages yet, so pass null and register the plugins to compute in place (SSR, tests, scripts):

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)