createIndicator(indicator, isStack?, paneOptions?)
createIndicator create an indicator.
Reference
typescript
(
indicator: string | {
name: string
id?: string
shortName?: string
precision?: number
calcParams?: unknown[]
shouldOhlc?: boolean
shouldFormatBigNumber?: boolean
visible?: boolean
zLevel?: number
extendData?: unknown
series?: 'normal' | 'price' | 'volume',
figures?: Array<{
key: string
title?: string
type?: string
baseValue?: number
attrs?: (params: object) => object
styles?: (params: object) => object
}>
minValue?: number
maxValue?: number
styles?: Partial<IndicatorStyle>
shouldUpdate?: (prev: Indicator, current: Indicator) => (boolean | { calc: boolean, draw: boolean })
calc?: (kLineDataList: KLineData[], indicator: Indicator) => Record<Timestamp, unknown> | Promise<Record<Timestamp, unknown>>
regenerateFigures?: (calcParams: unknown[]) => Array<{
key: string
title?: string
type?: string
baseValue?: number
attrs?: (params: object) => object
styles?: (params: object) => object
}>
createTooltipDataSource?: (params: object) => ({
name?: string
calcParamsText?: string
features?: Array<{
id?: string
position?: 'left' | 'middle' | 'right'
marginLeft?: number
marginTop?: number
marginRight?: number
marginBottom?: number
paddingLeft?: number
paddingTop?: number
paddingRight?: number
paddingBottom?: number
size?: number
color?: string
activeColor?: string
backgroundColor?: string
activeBackgroundColor?: string
type?: 'path' | 'icon_font'
path?: {
style?: 'stroke' | 'fill'
path?: string
lineWidth?: number
}
iconFont?: {
content?: string
family?: string
}
}>
legends?: Array<{
title: string |
{
text: string
color: string
}
value: string |
{
text: string
color: string
}
}>
})
draw?: (params: object) => boolean
onDataStateChange?: (params: object) => void
},
isStack?: boolean,
paneOptions: {
id?: string
height?: number
minHeight?: number
dragEnabled?: boolean
order?: number
state?: 'normal' | 'maximize' | 'minimize'
axis?: {
name: string
reverse?: boolean
inside?: boolean
position?: 'left' | 'right'
scrollZoomEnabled?: boolean
gap?: {
top?: number
bottom?: number
}
createRange?: (params: object) => ({
from: number
to: number
range: number
realFrom: number
realTo: number
realRange: number
displayFrom: number
displayTo: number
displayRange: number
})
createTicks?: (params: object) => Array<{
coord: number
value: number | string
text: string
}>
}
}
) => string | nullParameters
indicatorIndicator configuration can be an indicator name or an object. The object parameters are as follows.nameName.idIndicator id.shortNameA short name, used for prompt display.precisionPrecision.calcParamsCalculate the parameters.shouldOhlcWhether to show theohlcbar.shouldFormatBigNumberWhether big numbers need to be formatted and displayed.visibleWhether it is visible.zLevelHierarchy only works between indicators.extendDataCustom the extended data.seriesSeries, supportsnormal,priceandvolume, whenpriceandprecisionis not set, the precision will follow the price precision, whenvolumeandprecisionis not set, the precision will follow the volume precision.figuresFigure configuration, an array of items containingobjectconfiguration.keyThe identifier of the data value, corresponding to thekeyof the data sub-item returned bycalc.typeThe type of figure that supports the type returned byklinecharts.getSupportedFigures.baseValueThe basic control value, currently only works whentypeisrectandbar. When this value is valid, the graphics will be drawn up and down based on this value.attrsThe property value is a method, and the return value is the required property of the object obtained byklinecharts.getFigureClass.stylesStyle is a method that returns the style required by the object obtained byklinecharts.getFigureClass.
minValueSpecify a minimum value.maxValueSpecifies the maximum value.stylesStyle configuration, the type is the same asindicatorin the general styleStyles.shouldUpdateControl whether updates are needed.calcCalculation method.regenerateFiguresRegenerates the basic graphics configuration. This is triggered whencalcParamschanges. The return value type is the same asfigures.createTooltipDataSourceCreate custom prompts.drawCustom drawing method, if the return value istrue, it will override the default drawing.onDataStateChangeData change callback notification.
isStackWhether to stack.paneOptionsPane configuration.idPane id.heightHeight.minHeightMin height.dragEnabledWhether the height can be adjusted by dragging.orderOrder.stateState, supportsnormal,maximizeandminimize.axisAxis configuration.nameThe name of the axis.reverseWhether to reverse.insideWhether it is inside.positionPosition, supportsleftandright.scrollZoomEnabledWhether to allow scrolling and zooming.gapTop and bottom margin configuration.topTop margin.bottomBottom margin.
createRangeCreate an axis value range callback method.createTicksCreate ticks information callback method.
Returns
createIndicator returns indicator id string or null .