k 线定位显示方法的关键点是当前图表价格和时间两个元素组成的坐标系,与屏幕定位显示方式不同,所以必须采用另一个标准模块 iBarText()。源码范例如下:
- #property copyright "Copyright 2012, laoyee"
- #property link "http://www.docin.com/yiwence"
- //新价格到达时运行一次
- int start()
- {
- return(0);
- }
- //程序加载时运行一次
- int init()
- {
- iBarText("5",5,Low[5],"黑体",14,Red);
- iBarText("r",5,Low[5],"wingdings 3",18,Blue);
- return(0);
- }
- //程序卸载时运行一次
- int deinit()
- {
- return(0);
- }
- /*
- 函 数:标注 k 线文字
- 参数说明:string myString 文字内容,在指定的蜡烛位置显示文字
- int myBarPos 指定 k 线序号
- double myPrice 指定价格
- string myDocStyle 指定字符集
- int myDocSize 指定字体
- color myColor 指定颜色
- 函数返回:在指定的 k 线价格位置上标注文字
- */
- void iBarText(string myString,int myBarPos,double myPrice,string myDocStyle,int myDocSize,color myColor)
- {
- string TextBarString=myString+Time[myBarPos]; //定义文本对象名称
- ObjectCreate(TextBarString,OBJ_TEXT,"",Time[myBarPos],myPrice); //建立一个文本对象
- ObjectSetText(TextBarString,myString,myDocSize,myDocStyle,myColor);//文字内容
- }
复制代码
在第 5 个 k 线最低价位置分别显示蓝色三角符号和红色数字 5。
|