1、通达信两线之间距离公式通达信指标公式编辑提供有很多相关的功能函数,我喜欢用DRAWRECTREL、DRAWTEXT_FIX这两个函数。我们打开编辑器的插入函数,在绘图函数中可以找到这两个,其原型如下:1.相对位置上画矩形.用法:DRAWRECTREL(LEFT,TOP,RIGHT,BOTTOM,COLOR),以图形窗口(LEFT,TOP)为左上角,(RIGHT,BOTTOM)为右下角绘制矩形,坐标单位是窗口沿水平和垂直方向的1/1000,取值范围是0999,超出范围则可能显示在图形窗口外,矩形中间填充颜色COLOR,COLOR为0表示不填充.例如: DRAWRECTREL(0,0,500,50
2、0,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为左对
3、齐,1为右对齐.例如: DRAWTEXT_FIX(CURRBARSCOUNT=1 AND CLOSE/OPEN1.08,0.5,0.5,0,大阳线)表示最后一个交易日实体阳线大于8%时在窗口中间位置显示大阳线字样.若文字中含有&,则进行折行此处补充:此函数与上面函数坐标定位上有差异,(X,Y)是给定点文字书写的起点,并且是用小数表示,即范围在0-1之间,(函数内部处理应该是用的百分比计算)。以下为实例应用代码:参数:录入EPS 0 1 0DRAWRECTREL(0,0,999,999,RGB(1,1,1);DRAWRECTREL(0,160,999,160.3,RGB(110,110,110)
4、;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,R
5、GB(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,方便演示改为下一
6、句直接给0预测均值:=0;XA:=FINONE(1,YEAR2,1231);XB:=IF(MONTH=4,1,0);XC:=IF(XB,XA,预测均值);XD:=TDXDLL5(69,SN,C,O); 此处同上原因,直接给收盘价CXD:=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(
7、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,
8、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;
9、DRAWTEXT_FIX(ISLASTBAR,X1+X2*1,Y1+Y2*1,1,CON2STR(FINONE(1,YEAR6,1231),2),COLORYELLOW;DRAWTEXT_FIX(ISLASTBAR,X1+X2*1,Y1+Y2*2,1,CON2STR(FINONE(1,YEAR5,1231),2),COLORYELLOW;DRAWTEXT_FIX(ISLASTBAR,X1+X2*1,Y1+Y2*3,1,CON2STR(FINONE(1,YEAR4,1231),2),COLORYELLOW;DRAWTEXT_FIX(ISLASTBAR,X1+X2*1,Y1+Y2*4,1,CON2
10、STR(FINONE(1,YEAR3,1231),2),COLORYELLOW;DRAWTEXT_FIX(ISLASTBAR AND XB=1,X1+X2*1,Y1+Y2*5,1,CON2STR(XC,2),COLORYELLOW;DRAWTEXT_FIX(ISLASTBAR AND XB=0,X1+X2*1,Y1+Y2*5,1,CON2STR(XC,2),COLORMAGENTA;DRAWTEXT_FIX(ISLASTBAR,X_A,Y1+Y2*6,1,XE_T),COLORMAGENTA;DRAWTEXT_FIX(ISLASTBAR,X1+X2*2+0.02,Y1+Y2*1,1,CON2S
11、TR(REF(C,5),2),COLORYELLOW;DRAWTEXT_FIX(ISLASTBAR,X1+X2*2+0.02,Y1+Y2*2,1,CON2STR(REF(C,4),2),COLORYELLOW;DRAWTEXT_FIX(ISLASTBAR,X1+X2*2+0.02,Y1+Y2*3,1,CON2STR(REF(C,3),2),COLORYELLOW;DRAWTEXT_FIX(ISLASTBAR,X1+X2*2+0.02,Y1+Y2*4,1,CON2STR(REF(C,2),2),COLORYELLOW;DRAWTEXT_FIX(ISLASTBAR,X1+X2*2+0.02,Y1+
12、Y2*5,1,CON2STR(REF(C,1),2),COLORYELLOW;DRAWTEXT_FIX(ISLASTBAR,X1+X2*2+0.02,Y1+Y2*6,1,CON2STR(REF(C,0),2),COLORYELLOW;DRAWTEXT_FIX(ISLASTBAR,X1+X2*3+0.05,Y1+Y2*1,1,CON2STR(预测均值/FINONE(1,YEAR6,1231),2),COLORYELLOW;DRAWTEXT_FIX(ISLASTBAR,X1+X2*3+0.05,Y1+Y2*2,1,CON2STR(预测均值/FINONE(1,YEAR5,1231),2),COLOR
13、YELLOW;DRAWTEXT_FIX(ISLASTBAR,X1+X2*3+0.05,Y1+Y2*3,1,CON2STR(预测均值/FINONE(1,YEAR4,1231),2),COLORYELLOW;DRAWTEXT_FIX(ISLASTBAR,X1+X2*3+0.05,Y1+Y2*4,1,CON2STR(预测均值/FINONE(1,YEAR3,1231),2),COLORYELLOW;DRAWTEXT_FIX(ISLASTBAR,X1+X2*3+0.05,Y1+Y2*5,1,CON2STR(预测均值/FINONE(1,YEAR2,1231),2),COLORYELLOW;DRAWTEXT
14、_FIX(ISLASTBAR,X1+X2*4+0.05,Y1+Y2*1,1,CON2STR(C/REF(C,5),2),COLORYELLOW;DRAWTEXT_FIX(ISLASTBAR,X1+X2*4+0.05,Y1+Y2*2,1,CON2STR(C/REF(C,4),2),COLORYELLOW;DRAWTEXT_FIX(ISLASTBAR,X1+X2*4+0.05,Y1+Y2*3,1,CON2STR(C/REF(C,3),2),COLORYELLOW;DRAWTEXT_FIX(ISLASTBAR,X1+X2*4+0.05,Y1+Y2*4,1,CON2STR(C/REF(C,2),2),
15、COLORYELLOW;DRAWTEXT_FIX(ISLASTBAR,X1+X2*4+0.05,Y1+Y2*5,1,CON2STR(C/REF(C,1),2),COLORYELLOW;DRAWTEXT_FIX(ISLASTBAR AND C/REF(C,5)预测均值/FINONE(1,YEAR6,1231),X1+X2*5+0.03,Y1+Y2*1,1,高估),COLORRED;DRAWTEXT_FIX(ISLASTBAR AND C/REF(C,4)预测均值/FINONE(1,YEAR5,1231),X1+X2*5+0.03,Y1+Y2*2,1,高估),COLORRED;DRAWTEXT_F
16、IX(ISLASTBAR AND C/REF(C,3)预测均值/FINONE(1,YEAR4,1231),X1+X2*5+0.03,Y1+Y2*3,1,高估),COLORRED;DRAWTEXT_FIX(ISLASTBAR AND C/REF(C,2)预测均值/FINONE(1,YEAR3,1231),X1+X2*5+0.03,Y1+Y2*4,1,高估),COLORRED;DRAWTEXT_FIX(ISLASTBAR AND C/REF(C,1)预测均值/FINONE(1,YEAR2,1231),X1+X2*5+0.03,Y1+Y2*5,1,高估),COLORRED;DRAWTEXT_FIX(
17、ISLASTBAR AND C/REF(C,5)=预测均值/FINONE(1,YEAR6,1231),X1+X2*5+0.03,Y1+Y2*1,1,低估),COLORGREEN;DRAWTEXT_FIX(ISLASTBAR AND C/REF(C,4)=预测均值/FINONE(1,YEAR5,1231),X1+X2*5+0.03,Y1+Y2*2,1,低估),COLORGREEN;DRAWTEXT_FIX(ISLASTBAR AND C/REF(C,3)=预测均值/FINONE(1,YEAR4,1231),X1+X2*5+0.03,Y1+Y2*3,1,低估),COLORGREEN;DRAWTEX
18、T_FIX(ISLASTBAR AND C/REF(C,2)=预测均值/FINONE(1,YEAR3,1231),X1+X2*5+0.03,Y1+Y2*4,1,低估),COLORGREEN;DRAWTEXT_FIX(ISLASTBAR AND C/REF(C,1)=预测均值/FINONE(1,YEAR2,1231),X1+X2*5+0.03,Y1+Y2*5,1,低估),COLORGREEN;DRAWTEXT_FIX(ISLASTBAR,0.975,0.08,0,七),COLORCYAN;DRAWTEXT_FIX(ISLASTBAR,0.975,0.25,0,月),COLORCYAN;DRAWT
19、EXT_FIX(ISLASTBAR,0.975,0.43,0,之),COLORCYAN;DRAWTEXT_FIX(ISLASTBAR,0.975,0.61,0,夜),COLORCYAN;DRAWTEXT_FIX(ISLASTBAR,0.975,0.80,0,著),COLORCYAN;DRAWTEXT_FIX(ISLASTBAR,0.76,Y1,0,使 用 说 明),COLORCYAN;DRAWTEXT_FIX(ISLASTBAR,0.62,Y1+Y2*1,0,1.通过网站等收集机构对每股收益预测;),COLORBROWN;DRAWTEXT_FIX(ISLASTBAR,0.62,Y1+Y2*2,
20、0,2.手工计算,机构对个股下一年度收益预测的平均值;),COLORBROWN;DRAWTEXT_FIX(ISLASTBAR,0.62,Y1+Y2*3,0,3.确定主图为年K线(设定模板时绑定周期)、不复权;),COLORBROWN;DRAWTEXT_FIX(ISLASTBAR,0.62,Y1+Y2*4,0,4.请查看指标用法注释,按方法录入预估收益;),COLORBROWN;DRAWTEXT_FIX(ISLASTBAR,0.62,Y1+Y2*5,0,5.评估结果会自动显示,高估红色低估绿色;),COLORBROWN;DRAWTEXT_FIX(ISLASTBAR,0.62,Y1+Y2*6,0,6.详情请参阅开宇老师BKD春季精英班课程,谢谢!),COLORBROWN;
copyright@ 2008-2022 冰豆网网站版权所有
经营许可证编号:鄂ICP备2022015515号-1