把这个通达信的趋势线源码改为飞狐
2019/12/4 17:55:51
公式编写说明:
n1:=20;AA1:=BACKSET(ISLASTBAR,PEAKBARS(1,N,1)+1);AA2:=AA1>REF(AA1,1);BB1:=BACKSET(ISLASTBAR,PEAKBARS(1,N,2)+1);BB2:=BB1>REF(BB1,1);CC1:=BACKSET(ISLASTBAR,PEAKBARS(1,N,3)+1);CC2:=CC1>REF(CC1,1);AA11:=BACKSET(ISLASTBAR,TROUGHBARS(2,N,1)+1);AA21:=AA11>REF(AA11,1);BB11:=BACKSET(ISLASTBAR,TROUGHBARS(2,N,2)+1);BB21:=BB11>REF(BB11,1);CC11:=BACKSET(ISLASTBAR,TROUGHBARS(2,N,3)+1);CC21:=CC11>REF(CC11,1);①:DRAWLINE(BB2,H,AA2,H,1),COLORBLUE;②:DRAWLINE(CC2,H,BB2,H,1),COLORCC6633;③:IF(AA1,PEAK(1,N,1),DRAWNULL),COLORFFAA00;④:DRAWLINE(CC2,H,AA2,H,1),COLORLIBLUE;⑤:DRAWLINE(BB21,L,AA21,L,1),COLORYELLOW;⑥:DRAWLINE(CC21,L,BB21,L,1),COLORFF00FF;⑦:DRAWLINE(CC21,L,AA21,L,1),COLORBROWN;⑧:IF(AA11,TROUGH(2,N,1),DRAWNULL),COLORRED;{N1:20;N2:10;N3:5}AA:=REF(H,N1)=HHV(H,2*N1+1);QY:=BACKSET(AA,N1+1);CC:=FILTER(QY,N1) AND H=HHV(H,N1+1);DDD:=BARSLAST(CC);GDTS:=IF(CC,CURRBARSCOUNT,0);DINGBU:=IF(DDD,REF(H,DDD),H);{顶部}DINGBUTS:=IF(DDD,REF(GDTS,DDD),GDTS);DINGBU1:=REF(DINGBU,DDD+1);GDCS1:=CONST(DINGBUTS);DINGBUTS1:=REF(DINGBUTS,DDD+1);GDCS2:=CONST(DINGBUTS1);DINGBU2:=REF(DINGBU1,DDD+1);MM:=IF(CURRBARSCOUNT>GDCS2,0,1);高点压力:DRAWLINE(CURRBARSCOUNT=GDCS2,H,CURRBARSCOUNT=GDCS1,H,1) COLORLIBLUE;DRAWLINE(CURRBARSCOUNT=GDCS2,H,ISLASTBAR,REF(H,GDCS2-1),1),COLOR0055FF,POINTDOT,LINETHICK2;DRAWLINE(CURRBARSCOUNT=GDCS1,H,ISLASTBAR,REF(H,GDCS1-1),1),COLORYELLOW,POINTDOT,LINETHICK2;AAA1:=REF(L,N1)=LLV(L,2*N1+1);QY1:=BACKSET(AAA1,N1+1);CCC1:=FILTER(QY1,N1) AND L=LLV(L,N1+1);DD1:=BARSLAST(CCC1);DDTS:=IF(CCC1,CURRBARSCOUNT,0);YDB:=IF(DD1,REF(L,DD1),L);DDTS1:=IF(DD1,REF(DDTS,DD1),DDTS);DDCS1:=CONST(DDTS1);ZDB:=REF(YDB,DD1+1);DDTS2:=REF(DDTS1,DD1+1);DDCS2:=CONST(DDTS2);低点支撑:DRAWLINE(CURRBARSCOUNT=DDCS2,L,CURRBARSCOUNT=DDCS1,L,1) COLORMAGENTA;DRAWLINE(CURRBARSCOUNT=DDCS2,L,ISLASTBAR,REF(L,DDCS2-1),1),COLOR0055FF,POINTDOT,LINETHICK2;DRAWLINE(CURRBARSCOUNT=DDCS1,L,ISLASTBAR,REF(L,DDCS1-1),1),COLORYELLOW,POINTDOT,LINETHICK2;
公式源码示例:
n:=5;
n1:=20;
AA1:=BACKSET(ISLASTBAR,PEAKBARS(1,N,1)+1);
AA2:=AA1>REF(AA1,1);
BB1:=BACKSET(ISLASTBAR,PEAKBARS(1,N,2)+1);
BB2:=BB1>REF(BB1,1);
CC1:=BACKSET(ISLASTBAR,PEAKBARS(1,N,3)+1);
CC2:=CC1>REF(CC1,1);
AA11:=BACKSET(ISLASTBAR,TROUGHBARS(2,N,1)+1);
AA21:=AA11>REF(AA11,1);
BB11:=BACKSET(ISLASTBAR,TROUGHBARS(2,N,2)+1);
BB21:=BB11>REF(BB11,1);
CC11:=BACKSET(ISLASTBAR,TROUGHBARS(2,N,3)+1);
CC21:=CC11>REF(CC11,1);
①:DRAWLINE(BB2,H,AA2,H,1),COLORBLUE;
②:DRAWLINE(CC2,H,BB2,H,1),COLORCC6633;
③:PARTLINE(ref(AA1,1),PEAK(1,N,1)),COLORFFAA00;
④:DRAWLINE(CC2,H,AA2,H,1),COLORC0C000;
⑤:DRAWLINE(BB21,L,AA21,L,1),COLORYELLOW;
⑥:DRAWLINE(CC21,L,BB21,L,1),COLORFF00FF;
⑦:DRAWLINE(CC21,L,AA21,L,1),COLORBROWN;
⑧:PARTLINE(REF(AA11,1),TROUGH(2,N,1)),COLORRED;
AA:=REF(H,N1)=HHV(H,2*N1+1);
QY:=BACKSET(AA,N1+1);
CC:=FILTER(QY,N1) AND H=HHV(H,N1+1);
CURRBARSCOUNT:=DATACOUNT-BARPOS+1;
DDD:=BARSLAST(CC);
GDTS:=IF(CC,CURRBARSCOUNT,0);
DINGBU:=IF(DDD,REF(H,DDD),H);{顶部}
DINGBUTS:=IF(DDD,REF(GDTS,DDD),GDTS);
DINGBU1:=REF(DINGBU,DDD+1);
GDCS1:=DINGBUTS[DATACOUNT];
DINGBUTS1:=REF(DINGBUTS,DDD+1);
GDCS2:=DINGBUTS1[DATACOUNT];
DINGBU2:=REF(DINGBU1,DDD+1);
MM:=IF(CURRBARSCOUNT>GDCS2,0,1);
高点压力:DRAWLINE(CURRBARSCOUNT=GDCS2,H,CURRBARSCOUNT=GDCS1,H,1),COLORC0C000;
DRAWLINE(CURRBARSCOUNT=GDCS2,H,ISLASTBAR,REF(H,GDCS2-1),1),COLOR0055FF,POINTDOT;
DRAWLINE(CURRBARSCOUNT=GDCS1,H,ISLASTBAR,REF(H,GDCS1-1),1),COLORYELLOW,POINTDOT;
AAA1:=REF(L,N1)=LLV(L,2*N1+1);
QY1:=BACKSET(AAA1,N1+1);
CCC1:=FILTER(QY1,N1) AND L=LLV(L,N1+1);
DD1:=BARSLAST(CCC1);
DDTS:=IF(CCC1,CURRBARSCOUNT,0);
YDB:=IF(DD1,REF(L,DD1),L);
DDTS1:=IF(DD1,REF(DDTS,DD1),DDTS);
DDCS1:=DDTS1[DATACOUNT];
ZDB:=REF(YDB,DD1+1);
DDTS2:=REF(DDTS1,DD1+1);
DDCS2:=DDTS2[DATACOUNT];
低点支撑:DRAWLINE(CURRBARSCOUNT=DDCS2,L,CURRBARSCOUNT=DDCS1,L,1) COLORMAGENTA;
DRAWLINE(CURRBARSCOUNT=DDCS2,L,ISLASTBAR,REF(L,DDCS2-1),1),COLOR0055FF,POINTDOT;
DRAWLINE(CURRBARSCOUNT=DDCS1,L,ISLASTBAR,REF(L,DDCS1-1),1),COLORYELLOW,POINTDOT;
看 股吧公式 www.ka nguba.com
其它股票公式列表