输入/搜索内容
内置函数
结构体
Ticker
Depth
OrderBook
Trade
Record
Market
Order
Condition
Account
Asset
Position
Funding
其它结构
HttpQuery-options
HttpQuery-return
LogStatus-table
LogStatus-btnTypeOne
LogStatus-btnTypeTwo
状态栏组件
Chart-options
Chart-return
KLineChart-options
KLineChart-return
SetData-data
EventLoop-return
exchange.Go-return
DBExec-return
Dial-return
Thread.join-return
内置变量与常量
通用约定
交易所

KLineChart函数返回的图表对象,以类似Pine语言的方式在K线上画图。遍历K线时,每根K线的画图操作以begin(bar)开始、以close(bar)结束。

属性

名称类型描述

begin(bar)

function

开始在一根K线上画图,参数为Record。每根K线的画图操作必须以begin(bar)开始、以close(bar)结束。

close(bar)

function

结束当前K线上的画图。Rust中为close(),不传参数。

barcolor(color, offset, editable, show_last, title, display)

function

设置K线颜色。display可选none、all。

bgcolor(color, offset, editable, show_last, title, display, overlay)

function

用指定颜色填充K线的背景。display可选none、all。

plot(series, title, color, linewidth, style, trackprice, histbase, offset, join, editable, show_last, display, overlay)

function

画一条数据线,返回线的编号(供fill()使用)。style、display的取值见备注。

fill(plot1, plot2, color, title, editable, show_last, fillgaps, display)

function

用颜色填充两条线(plot()或hline()的返回值)之间的背景。display可选none、all。

hline(price, title, color, linestyle, linewidth, editable, display, overlay)

function

在固定价格处画水平线。linestyle可选dashed、dotted、solid;display可选none、all。

plotarrow(series, title, colorup, colordown, offset, minheight, maxheight, editable, show_last, display, overlay)

function

画向上、向下的箭头(数值为正向上,为负向下)。display可选none、all。

plotshape(series, title, style, location, color, offset, text, textcolor, editable, size, show_last, display, overlay)

function

画形状。style、location、size、display的取值见备注。

plotchar(series, title, char, location, color, offset, text, textcolor, editable, size, show_last, display, overlay)

function

用任意Unicode字符画形状。location、size、display的取值同plotshape()。

plotcandle(open, high, low, close, title, color, wickcolor, editable, show_last, bordercolor, display, overlay)

function

画K线。display可选none、all。

signal(direction, price, qty, id)

function

Pine语言没有的方法,画买卖信号。direction可选long、closelong、short、closeshort;price为标记的纵轴位置;qty为交易数量;id可选,替换默认显示的文字(默认为交易方向)。

reset(remain)

function

Pine语言没有的方法,清空图表数据;remain为保留的数据条数,不传时清空全部。Rust中必须传入remain。

参考

备注

参数列表中第一个参数之后的参数都可以省略。JavaScript不能按参数名传参,用一个{参数名: 值}对象指定,例如c.fill(h, l, {color: "rgba(255, 0, 0, 0.2)", title: "fill"})、c.plotshape(bar.Low, {style: "diamond"});Python使用关键字参数,例如c.plotshape(bar.Low, style = "diamond");Rust中各方法的最后一个参数是JSON字符串形式的选项(没有选项时传"{}"),例如c.plot(bar.High, r#"{"title": "high"}"#),plotshape()、plotchar()的第一个参数为布尔值,为真时在该K线上画出。

颜色可以写作"rgba(255, 0, 0, 0.2)"或"#FF0000"。

plot()参数的取值:style可选stepline_diamond、stepline、cross、areabr、area、circles、columns、histogram、linebr、line;display可选none、all。数值传NaN(Python为None)时该点不画,配合linebr可以画不连续的线。

plotshape()参数的取值:style可选diamond、square、label_down、label_up、arrow_down、arrow_up、circle、flag、triangle_down、triangle_up、cross、xcross;location可选abovebar、belowbar、top、bottom、absolute;size可选10px、14px、20px、40px、80px(对应Pine语言的size.tiny、size.small、size.normal、size.large、size.huge,size.auto即size.small);display可选none、all。