KLineChart-return
KLineChart函数返回的图表对象,以类似Pine语言的方式在K线上画图。遍历K线时,每根K线的画图操作以begin(bar)开始、以close(bar)结束。
属性
| 名称 | 类型 | 描述 |
begin(bar) | function | 开始在一根K线上画图,参数为 |
close(bar) | function | 结束当前K线上的画图。 |
barcolor(color, offset, editable, show_last, title, display) | function | 设置K线颜色。 |
bgcolor(color, offset, editable, show_last, title, display, overlay) | function | 用指定颜色填充K线的背景。 |
plot(series, title, color, linewidth, style, trackprice, histbase, offset, join, editable, show_last, display, overlay) | function | 画一条数据线,返回线的编号(供 |
fill(plot1, plot2, color, title, editable, show_last, fillgaps, display) | function | 用颜色填充两条线( |
hline(price, title, color, linestyle, linewidth, editable, display, overlay) | function | 在固定价格处画水平线。 |
plotarrow(series, title, colorup, colordown, offset, minheight, maxheight, editable, show_last, display, overlay) | function | 画向上、向下的箭头(数值为正向上,为负向下)。 |
plotshape(series, title, style, location, color, offset, text, textcolor, editable, size, show_last, display, overlay) | function | 画形状。 |
plotchar(series, title, char, location, color, offset, text, textcolor, editable, size, show_last, display, overlay) | function | 用任意Unicode字符画形状。 |
plotcandle(open, high, low, close, title, color, wickcolor, editable, show_last, bordercolor, display, overlay) | function | 画K线。 |
signal(direction, price, qty, id) | function | Pine语言没有的方法,画买卖信号。 |
reset(remain) | function | Pine语言没有的方法,清空图表数据; |
参考
备注
参数列表中第一个参数之后的参数都可以省略。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。