由于在飞狐里无法使用画直线函数 DRAWLINE 作为变量引用,只能使用飞狐的趋势线数值函数 LINEVALUE 代替,但因为此函数的特殊性质『估计此函数设计出来就是为了预警使用的』,相同的画线条件在个股图形中只能显示最新成立的一段画线,无法在历史图形中显示,这个也是无奈之举,如果哪位老师有更好的方法解决 通达信 画直线函数 DRAWLINE 在飞狐中的变量引用问题,请一定指教,我这里先万分感谢了
源码
MACD:"MACD.MACD",LINETHICK;
W1:STICKLINE(MACD>0,MACD,0,8,1),COLORRED;
W2:STICKLINE(MACD<0,MACD,0,8,1),COLORCYAN;
VA1:=HHVBARS(MACD,BARSLAST(MACD<0)+1);
VA2:=CROSS(BACKSET(CROSS(0,MACD),REF(VA1,1)+2),0.5);
QG:=CROSS(BACKSET(CROSS(0,MACD) OR (ISLASTBAR AND MACD>0),REF(VA1,1)+2),0.5);
前高:LINEVALUE(VA2,MACD,REF(VA2,1),REF(MACD,1),0,0),COLORMAGENTA;
VA3:=LLVBARS(MACD,BARSLAST(MACD>0)+1);
VA4:=CROSS(BACKSET(CROSS(MACD,0),REF(VA3,1)+2),0.5);
BD:=BARSLAST(FILTERX(CROSS(0,MACD),BARSCOUNT(C)));
前低:LINEVALUE(VA4,MACD,REF(VA4,1),REF(MACD,1),0,0);
BDTJ:=IF(MACD<0,FILTERX(MACD=LLV(MACD,BARSLAST(MACD>0)),
BARSCOUNT(C)),0);
TSBDTJ:=BARSLAST(BDTJ);
ZQ:=DATACOUNT-BARPOS;
BDZH:=FILTERX(MACD<REFX(LLV(MACD,BD+1),ZQ),BARSCOUNT(C));
BDTS:=BARSLAST(BDZH);
本低:IF(BD+1>=1,REFX(LLV(MACD,BD+1),ZQ),0),LINETHICK;
PARTLINE(BD+1>=1,REFX(LLV(MACD,BD+1),ZQ));
BDCL:=CROSS(COUNT(CROSS(MACD>本低/2 AND MACD<0,0.5),TSBDTJ)=1,0.5) AND TSBDTJ>=0;
终点:=IF(ISLASTBAR AND MACD>0 AND MACD=HHV(MACD,BARSLAST(MACD<0)),1,
IF(FILTERX(QG,BARSCOUNT(C)),2,0));
UU:=(终点=1 OR 终点=2) AND MACD>0;
ZZ:=FILTERX(UU,BARSCOUNT(C));
本高:LINEVALUE(ZZ,MACD,REF(ZZ,1),REF(MACD,1),0,0),COLORWHITE;
横线:=REFX(REF(MACD,BARSLAST(ZZ)),ZQ);
WW:=MACD>横线;
起始点:=FILTERX(REFX(BARSLAST(WW),1)=1,BARSCOUNT(C));
天数┃:BARSLAST(起始点),COLORYELLOW,LINETHICK;
上横线:LINEVALUE(起始点,横线,ZZ,横线,0,0),COLORGREEN,LINEDOT;
下横线:DRAWLINE(BDZH,REFX(LLV(MACD,BD+1),ZQ),BDTJ=1,MACD,0),COLOR8080FF,LINEDOT;
DRAWNUMBER(BDTJ,REFX(LLV(MACD,BD+1),ZQ)*0.9,BDTS,2);
DRAWNUMBER(ZZ,上横线*1.1,天数┃,2);
AQ:=SETVAL(起始点,BARSLAST(ZZ),0-BARSLAST(ZZ),BARSLAST(ZZ));
TJ:=IF(起始点,AQ,0);
红柱数量:IF(天数┃>0 AND 天数┃<=REF(TJ,天数┃),SUM(MACD>0,天数┃),0),COLORWHITE,LINETHICK;
横线起始价:REF(C,天数),LINETHICK;
空间评估:(横线起始价-C)/C*100,LINETHICK;
TT:=BARSLAST(ZZ);
WQG:=CROSS(COUNT(CROSS(MACD<本高/2 AND MACD>0,0.5),ZZ)=1,0.5) AND ZZ>=0;
STICKLINE(MACD>前高 AND 本高>前高 AND BARSLAST(CROSS(MACD<本高/2,0.5))>0 AND
MACD>(前高+本高)/2,MACD,前高,2.6666666666666666666666666666667,0),COLORYELLOW;
前高本高二分位:IF(MACD>0 AND 本高<>前高,LINEVALUE(WQG,(前高+本高)/2,REF(WQG,1),REF((前高+本高)/2,1),0,0)
,0),COLORC0C000,LINEDOT,LINETHICK;
PARTLINE(MACD>0 AND 本高<>前高,LINEVALUE(WQG,(前高+本高)/2,REF(WQG,1),REF((前高+本高)/2,1),0,0)),COLORC0C000,LINEDOT;
AA:='〖'+'上升空间'+'〗'+NUMTOSTR(IF(空间评估,空间评估,0),2);
DRAWTEXTEX(C>0,1,0,1000,AA + '﹪'),COLORWHITE;
DRAWTEXT(WQG,MACD*1.1,'本高成立'),COLORWHITE;
DRAWTEXT(BDCL,MACD*1.1,'本低成立'),COLORWHITE;
STICKLINE(MACD>前高,MACD,前高,1,0),COLORYELLOW;
STICKLINE(WQG,MACD,0,2.6666666666666666666666666666667,0),COLORGREEN;
STICKLINE(MACD<0 AND MACD<前低 AND 前低<0,MACD,前低,2.6666666666666666666666666666667,0),COLORBLUE;
AQ1:=SETVAL(CROSS(MACD<0,0.5),BARSLAST(BDTJ),0-BARSLAST(BDTJ),BARSLAST(BDTJ));
B1:=IF(CROSS(MACD<0,0.5),AQ1,0);
TSB1:=BARSLAST(MACD>0)-1;
STICKLINE(BARSLAST(BDCL)>=0 AND MACD<前低 AND MACD<0,MACD,前低,2.6666666666666666666666666666667,0),COLORGREEN;
STICKLINE(BDCL,MACD,0,2.6666666666666666666666666666667,0),COLORWHITE;
STICKLINE(MACD>前高 AND 本高>前高 AND BARSLAST(WQG)>0,
MACD,前高,2.6666666666666666666666666666667,0),COLORRED;
DRAWTEXT(VA2 AND VA2<>UU,(MACD/10)*9,'前');
DRAWTEXT(VA2 AND VA2<>UU,MACD/10,'高');
DRAWTEXT(ZZ,(MACD/10)*9,'本'),COLORWHITE;
DRAWTEXT(ZZ,MACD/10,'高'),COLORWHITE;
DRAWTEXT(BDTJ,(MACD/10)*9,'低'),COLORRED;
DRAWTEXT(BDTJ,MACD/10,'本'),COLORRED;
PARTLINE(BARSLAST(BDCL)>=0,本低/2),COLORRED,LINEDOT;