文档
测试

6、绘图函数说明

POST

绘图函数

*注:以下函数均支持回测和实盘/模拟运行模式。

1)在界面上画图 ContextInfo.paint()

# 1)在界面上画图 ContextInfo.paint() 用法: ContextInfo.paint(name, value, index, line_style, color = ‘white’, limit = ‘’) 释义: 在界面上画图 参数: name:string,需显示的指标名 value:number,需显示的数值 index:number,显示索引位置,填 -1 表示按主图索引显示 line_style:number,线型,可取值: 0:曲线 42:柱状线 color:string,颜色(不填默认为白色)目前支持以下几种颜色: blue:蓝 brown:棕 cyan:蓝绿 green:绿 magenta:品红 red:红 white:白 yellow:黄 limit:string,画线控制,可取值: ‘noaxis’: 不影响坐标画线 ‘nodraw’ :不画线 返回: 无 示例: ```py def handlebar(ContextInfo): realtimetag = ContextInfo.get_bar_timetag(ContextInfo.barpos) value = ContextInfo.get_close_price('', '', realtimetag) ContextInfo.paint('close', value, -1, 0, 'white','noaxis') ```

2)在图形上显示文字 ContextInfo.draw_text()

# 2)在图形上显示文字 ContextInfo.draw_text() 用法: ContextInfo.draw_text(condition, position, text) 释义: 在图形上显示数字 参数: condition:条件 Position:位置 text:文字 返回: 无 示例: ```py def handlebar(ContextInfo): ContextInfo.draw_text(1, 10, '文字') ```

3)在图形上显示数字 ContextInfo.draw_number()

# 3)在图形上显示数字 ContextInfo.draw_number() 用法: ContextInfo.draw_number(cond, height, number, precision) 释义: 在图形上显示数字 参数: cond:bool,条件 height:number,显示文字的高度位置 text:string,显示的数字 precision:为小数显示位数(取值范围 0 - 7) 返回: 无 示例: ```py def handlebar(ContextInfo): close = ContextInfo.get_market_data(['close']) ContextInfo.draw_number(1 > 0, close, 66, 1) ```

4)在数字 1 和数字 2 之间绘垂直线 ContextInfo.draw_vertline()

## 4)在数字 1 和数字 2 之间绘垂直线 ContextInfo.draw_vertline() 用法: ContextInfo.draw_vertline(cond, number1, number2, color = ‘’, limit = ‘’) 释义: 在数字1和数字2之间绘垂直线 参数: cond:bool,条件 number1:number,数字1 number2:number,数字2 color:string,颜色(不填默认为白色)目前支持以下几种颜色: blue:蓝 brown:棕 cyan:蓝绿 green:绿 magenta:品红 red:红 white:白 yellow:黄 limit:string,画线控制,可取值: ‘noaxis’: 不影响坐标画线 ‘nodraw’ :不画线 返回: 无 示例: ```py def handlebar(ContextInfo): close = ContextInfo.get_market_data(['close']) open = ContextInfo.get_market_data(['open']) ContextInfo.draw_vertline(1 > 0, close, open, 'cyan') ```

5)在图形上绘制小图标 ContextInfo.draw_icon()

# 5)在图形上绘制小图标 ContextInfo.draw_icon() 用法: ContextInfo.draw_icon(cond, height, type) 释义: 在图形上绘制小图标 参数: cond:bool,条件 height:number,图标的位置 text:number,图标的类型,可取值: 1:椭圆 0:矩形 返回: 无 示例: ```py def handlebar(ContextInfo): close = ContextInfo.get_market_data(['close']) ContextInfo.draw_icon(1 > 0, close, 0) ```