通达信指标公式编辑提供有很多相关的功能函数,我喜欢用DRAWRECTREL、DRAWTEXT_FIX这两个函数。我们打开编辑器的插入函数,在绘图函数中可以到这两个,其原型如下:
1.相对位置上画矩形.
用法: DRAWRECTREL(LEFT,TOP,RIGHT,BOTTOM,COLOR),以图形窗口(LEFT,TOP)为左上角,(RIGHT,BOTTOM)为右下角绘制矩形,坐标单位是窗口沿水平和垂直方向的1/1000,取值范围是0—999,超出范围则可能显示在图形窗口外,矩形中间填充颜COLOR,COLOR为0表示不填充.
例如: DRAWRECTREL(0,0,500,500,RGB(255,255,0))表示在图形最左上部1/4位置用黄绘制矩形.
上面是指标编辑器里的用法解释已非常清楚,相信大家一看就知道如何用,补充一点,就是坐标范围,不管主图或副图窗口,都是默认宽0-999,高0-999,如主图给个起始点(500,500),表示从主图的中心点开始,终点用(999,999)表示主图窗口的右下角;多试几次就会用了。
2.固定位置显示文字;在指标排序中显示字符串栏目.
用法: DRAWTEXT_FIX(COND,X,Y,TYPE,TEXT),当COND条件满足时,在当前指标窗口内(X,Y)位置书写文字TEXT,X,Y为书写点在窗口中相对于左上角的百分比,TYPE:0为左对齐,1为右对齐.
例如: DRAWTEXT_FIX(CURRBARSCOUNT=1 AND CLOSE/OPEN>1.08,0.5,0.5,0,'大阳线')表示最后一个交易日实体阳线大于8%时在窗口中间位置显示'大阳线'字样.若文字中含有&,则进行折行
此处补充:此函数与上面函数坐标定位上有差异,(X,Y)是给定点文字书写的起点,并且是用小数表示,即范围在0-1之间,(函数内部处理应该是用的百分比计算)。通达信数字转字符串函数
以下为实例应用代码:
{参数:录入EPS 0 1 0}
DRAWRECTREL(0,0,999,999,RGB(1,1,1));
DRAWRECTREL(0,160,999,160.3,RGB(110,110,110));
DRAWRECTREL(350,840,615,840.3,RGB(110,110,110));
DRAWRECTREL(90,0,90.2,999,RGB(110,110,110));
DRAWRECTREL(200,0,200.2,999,RGB(110,110,110));
DRAWRECTREL(350,0,350.2,999,RGB(110,110,110));
DRAWRECTREL(455,0,455.2,840,RGB(110,110,110));
DRAWRECTREL(540,0,540.2,840,RGB(110,110,110));
DRAWRECTREL(615,0,615.2,999,RGB(110,110,110));
DRAWRECTREL(966,0,999,999,RGB(20,20,20));
X1:=0.06; X2:=0.10; X3:=0.075;
Y1:=0.05; Y2:=0.13; Y3:=0.25; Y4:=0.35; Y5:=0.45;
YEAR1:=YEAR;
YEAR2:=YEAR1-1;
YEAR3:=YEAR2-1;
YEAR4:=YEAR3-1;
YEAR5:=YEAR4-1;
YEAR6:=YEAR5-1;
SN:=STR2CON(CODE)+1000000;
{预测均值:=TDXDLL5(55,SN,录入EPS,录入EPS); 此处原为调用DLL,方便演示改为下一句直接给0}
预测均值:=0;
XA:=FINONE(1,YEAR2,1231);
XB:=IF(MONTH>=4,1,0);
XC:=IF(XB,XA,预测均值);
{XD:=TDXDLL5(69,SN,C,O); 此处同上原因,直接给收盘价C}
XD:=C;
XE_T:=IF(XD=1,'录入数据',IF(XD=YEAR1,CON2STR(预测均值,2),'注意更新'));
X_A:=IF(XD=1,X1+X2*1.15,IF(XD=YEAR1,X1+X2*1,X1+X2*1.15));
DRAWTEXT_FIX(ISLASTBAR,X1+0.005,Y1,1,'年 份'),COLORLIMAGENTA;
DRAWTEXT_FIX(ISLASTBAR,0.12,Y1,0,'每股收益'),COLORLIMAGENTA;
DRAWTEXT_FIX(ISLASTBAR,0.22,Y1,0,'年收盘价(不复权)'),COLORLIMAGENTA;
DRAWTEXT_FIX(ISLASTBAR,0.36,Y1,0,'每股收益增速'),COLORLIMAGENTA;
DRAWTEXT_FIX(ISLASTBAR,0.47,Y1,0,'股价增速'),COLORLIMAGENTA;
DRAWTEXT_FIX(ISLASTBAR,0.55,Y1,0,'评估结果'),COLORLIMAGENTA;
DRAWNUMBER_FIX(ISLASTBAR,X1,Y1+Y2*1,1,YEAR6),COLORWHITE;
DRAWNUMBER_FIX(ISLASTBAR,X1,Y1+Y2*2,1,YEAR5),COLORWHITE;
DRAWNUMBER_FIX(ISLASTBAR,X1,Y1+Y2*3,1,YEAR4),COLORWHITE;
DRAWNUMBER_FIX(ISLASTBAR,X1,Y1+Y2*4,1,YEAR3),COLORWHITE;
DRAWNUMBER_FIX(ISLASTBAR,X1,Y1+Y2*5,1,YEAR2),COLORWHITE;
DRAWNUMBER_FIX(ISLASTBAR,X1,Y1+Y2*6,1,YEAR1),COLORWHITE;
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。
发表评论