趋势比对通达信公式 副图 源码附图无未来函数
M1:=5;
M2:=10;
M3:=20;
M4:=60;
M5:=120;
MA1:MA(CLOSE,M1)LINETHICK1;
MA2:MA(CLOSE,M2)LINETHICK1;
MA3:MA(CLOSE,M3)LINETHICK2;
MA4:MA(CLOSE,M4)LINETHICK1;
MA5:MA(CLOSE,M5)LINETHICK1;
STICKLINE((C-REF(C,1))/REF(C,1)>0.095 AND C=H,C,O,1,0),COLOR00FFFF;
STICKLINE((REF(C,1)-C)/ REF(C,1) >0.097 AND C=L,C,O,1,0),COLORGREEN;
G:=MA(C,5);
D:=MA(C,10);
HH:=REF(H,5)=HHV(H,11);
LL:=REF(L,5)=LLV(L,11);
FG01:=BACKSET(HH,6)>BACKSET(HH,5) ;
FD01:=BACKSET(LL,6)>BACKSET(LL,5) ;
FG02:=IF(BARSLAST(FG01)=BARSLAST(FD01) AND G>D,FG01,IF(BARSLAST(FD01)>BARSLAST(FG01),FG01,0));
FD02:=IF(BARSLAST(FG01)=BARSLAST(FD01) AND D>G,FD01,IF(BARSLAST(FG01)>BARSLAST(FD01),FD01,0));
FG0:=FG02 AND H=HHV(H,BARSLAST(FD02));
FD0:=FD02 AND L=LLV(L,BARSLAST(FG02));
GP:=IF(FG0,H,DRAWNULL),CIRCLEDOT,COLORCYAN;
DP:=IF(FD0,L,DRAWNULL),CIRCLEDOT,COLORGREEN;
GQ:=L>REF(H,1) AND DAY!=REF(DAY,1);
DQ:=H<REF(L,1) AND DAY!=REF(DAY,1);
GQL:=REF(L,BARSLAST(GQ));
DQH:=REF(H,BARSLAST(DQ));
FGH:=REF(H,BARSLAST(FG0));
FGL:=REF(L,BARSLAST(FG0));
FGH1:=REF(H,BARSLAST(FG0)+1);
FGL1:=REF(L,BARSLAST(FG0)+1);
FGH2:=REF(H,BARSLAST(FG0)+2);
FGL2:=REF(L,BARSLAST(FG0)+2);
FDH:=REF(H,BARSLAST(FD0));
FDL:=REF(L,BARSLAST(FD0));
FDH1:=REF(H,BARSLAST(FD0)+1);
FDL1:=REF(L,BARSLAST(FD0)+1);
FDH2:=REF(H,BARSLAST(FD0)+2);
FDL2:=REF(L,BARSLAST(FD0)+2);
FGZH:=IF(FGL<=FGL1,FGH2,FGH1);
FGZL:=IF(FGH1<FGL,FGL,IF(FGL<=FGL1,FGL2,FGL1));
FDZH:=IF(FDL1>FDH,FDH,IF(FDH>=FDH1,FDH2,FDH1));
FDZL:=IF(FDH>=FDH1,FDL2,FDL1);
FG1:=FGH>FDZH AND FG0;
FD1:=FDL<FGZL AND FD0;
FG:=FG1 AND FGH>FDH AND FGL>FDL AND FGL1>FDL;
FD:=FD1 AND FDL<FGL AND FDH<FGH AND FDH1<FGH;
BH0:=(H<=REF(H,1) AND L>=REF(L,1)) OR (H>=REF(H,1) AND L<=REF(L,1));
BHG:=COUNT(BH0,BARSLAST(FD0));
BHD:=COUNT(BH0,BARSLAST(FG0));
BGQ:=COUNT(GQ,BARSLAST(FD0));
BDQ:=COUNT(DQ,BARSLAST(FG0));
BK0:=IF(BHG>0,BHG+2+1,IF(BHD,BHD+2+1,3));
BK:=IF(BGQ,BK0-BGQ,IF(BDQ,BK0-BDQ,BK0));
G1X:=(FG AND BARSLAST(FD)>BK);
D1X:=(FD AND BARSLAST(FG)>BK);
G1:=(FG0 AND REF(H,BARSLAST(FG0))>=REF(H,BARSLAST(G1X)) AND BARSLAST(D1X)>BARSLAST(G1X))
OR (FG1 AND COUNT(GQ,BARSLAST(FD1))>0 AND REF(H,BARSLAST(FG1))>REF(H,BARSLAST(G1X)));
D1:=(FD0 AND REF(L,BARSLAST(FD0))<=REF(L,BARSLAST(D1X)) AND BARSLAST(G1X)>BARSLAST(D1X))
OR (FD1 AND COUNT(DQ,BARSLAST(FG1))>0 AND REF(L,BARSLAST(FD1))<REF(H,BARSLAST(D1X)));
G1H:=IF(BARSLAST(D1)>BARSLAST(G1),REF(H,BARSLAST(G1)),REF(H,BARSLAST(D1))),;
D1L:=IF(BARSLAST(G1)>BARSLAST(D1),REF(L,BARSLAST(D1)),REF(L,BARSLAST(G1)));
G2:=G1 AND H=HHV(G1H,BARSLAST(D1)+1) AND H>REF(H,1) AND BARSLAST(D1)>BARSLAST(G1);
D2:=D1 AND L=LLV(D1L,BARSLAST(G1)+1) AND L<REF(L,1) AND BARSLAST(G1)>BARSLAST(D1);
G3:=G2 OR (FG0 AND REF(H,BARSLAST(FG0))>REF(H,BARSLAST(G2)) AND BARSLAST(D2)>BARSLAST(G2));
D3:=D2 OR (FD0 AND REF(L,BARSLAST(FD0))<REF(L,BARSLAST(D2)) AND BARSLAST(G2)>BARSLAST(D2));
GPB:=IF(G1X,H,DRAWNULL),,COLORYELLOW,LINETHICK2;
DPB:=IF(D1X,L,DRAWNULL),CIRCLEDOT,COLORYELLOW;
{画线}
NN:=G3;
UU:=D3;
L1:DRAWLINE(UU,L,NN, H,0),COLORYELLOW,DOTLINE;
L2:DRAWLINE(NN,H,UU, L,0),COLORWHITE,DOTLINE;
Z1:=STRCAT(HYBLOCK,' ');
Z2:=STRCAT(Z1,DYBLOCK);
Z3:=STRCAT(Z2,' ');
DRAWTEXT_FIX(ISLASTBAR,0,10,0,STRCAT(Z3,GNBLOCK)),COLOR0000FF;
DRAWTEXT_FIX(1,0.00,0.00,0,'主题投资:')COLOR0000FF;
DRAWTEXT_FIX(1,0.07,0.00,0,EXTERNSTR(0,1))COLOR0000FF;
DRAWTEXT_FIX(1,0.00,0.08,0,'主营业务:')COLORFF00FF;
DRAWTEXT_FIX(1,0.07,0.08,0,EXTERNSTR(0,2))COLORFF00FF;
流通市值:(FINANCE(40)/100000000),NODRAW,COLORRED;
未来函数检测结果如下:
该公式包含未来函数:BACKSET
该公式包含未来函数:FINANCE
解密、编写股票、期货策略请联系QQ或微信同号:88652583
相关股票指标公式
原理解析:
M1赋值:5
M2赋值:10
M3赋值:20
M4赋值:60
M5赋值:120
输出
MA1:收盘价的M1日简单移动平均LINETHICK1
输出
MA2:收盘价的M2日简单移动平均LINETHICK1
输出
MA3:收盘价的M3日简单移动平均 线宽为2
输出
MA4:收盘价的M4日简单移动平均LINETHICK1
输出
MA5:收盘价的M5日简单移动平均LINETHICK1
STICKLINE((C-1日前的C)/1日前的C>0.095 AND C=H,C,O,1,0),COLOR00FFFF
STICKLINE((1日前的C-C)/ 1日前的C >0.097 AND C=L,C,O,1,0),画绿色
G赋值:C的5日简单移动平均
D赋值:C的10日简单移动平均
HH赋值:5日前的H=11日内H最高值
LL赋值:5日前的L=11日内L最低值
FG01赋值:BACKSET(HH,6)>BACKSET(HH,5)
FD01赋值:BACKSET(LL,6)>BACKSET(LL,5)
FG02赋值:IF(上次FG01距今天数=BARSLAST(FD01) AND G>D,FG01,IF(BARSLAST(FD01)>上次FG01距今天数,FG01,0))
FD02赋值:IF(上次FG01距今天数=BARSLAST(FD01) AND D>G,FD01,IF(上次FG01距今天数>BARSLAST(FD01),FD01,0))
FG0赋值:FG02 AND H=HHV(H,上次FD02距今天数)
FD0赋值:FD02 AND L=LLV(L,上次FG02距今天数)
如果FG0返回H否则返回DRAWNULL
如果FD0返回L否则返回DRAWNULL
GQ:=L>1日前的H AND DAY!=1日前的DAY
DQ:=H<1日前的L AND DAY!=1日前的DAY
GQL:=REF(L,上次GQ距今天数)
DQH:=REF(H,上次DQ距今天数)
FGH赋值:REF(H,上次FG0距今天数)
FGL赋值:REF(L,上次FG0距今天数)
FGH1:=REF(H,上次FG0距今天数+1)
FGL1:=REF(L,上次FG0距今天数+1)
FGH2:=REF(H,上次FG0距今天数+2)
FGL2:=REF(L,上次FG0距今天数+2)
FDH赋值:REF(H,上次FD0距今天数)
FDL赋值:REF(L,上次FD0距今天数)
FDH1:=REF(H,上次FD0距今天数+1)
FDL1:=REF(L,上次FD0距今天数+1)
FDH2:=REF(H,上次FD0距今天数+2)
FDL2:=REF(L,上次FD0距今天数+2)
如果FGL<=FGL1返回FGH2否则返回FGH1
FGZL赋值:IF(FGH1
FDZH赋值:IF(FDL1>FDH,FDH,IF(FDH>=FDH1,FDH2,FDH1))
如果FDH>=FDH1返回FDL2否则返回FDL1
FG1赋值:FGH>FDZH AND FG0
FD1赋值:FDL
FG赋值:FG1 AND FGH>FDH AND FGL>FDL AND FGL1>FDL
FD赋值:FD1 AND FDL
BH0赋值:(H<=1日前的H AND L>=1日前的L) OR (H>=1日前的H AND L<=1日前的L)
BHG赋值:COUNT(BH0,上次FD0距今天数)
BHD赋值:COUNT(BH0,上次FG0距今天数)
BGQ赋值:COUNT(GQ,上次FD0距今天数)
BDQ赋值:COUNT(DQ,上次FG0距今天数)
BK0赋值:IF(BHG>0,BHG+2+1,IF(BHD,BHD+2+1,3))
BK赋值:IF(BGQ,BK0-BGQ,IF(BDQ,BK0-BDQ,BK0))
G1X:=(FG AND 上次FD距今天数>BK)
D1X:=(FD AND 上次FG距今天数>BK)
G1:=(FG0 AND REF(H,上次FG0距今天数)>=REF(H,BARSLAST(G1X)) AND BARSLAST(D1X)>BARSLAST(G1X))
OR (FG1 AND COUNT(GQ,BARSLAST(FD1))>0 AND REF(H,BARSLAST(FG1))>REF(H,BARSLAST(G1X)))
D1:=(FD0 AND REF(L,上次FD0距今天数)<=REF(L,BARSLAST(D1X)) AND BARSLAST(G1X)>BARSLAST(D1X))
OR (FD1 AND COUNT(DQ,BARSLAST(FG1))>0 AND REF(L,BARSLAST(FD1))
G1H:=IF(上次D1距今天数>BARSLAST(G1),REF(H,BARSLAST(G1)),REF(H,上次D1距今天数)),
D1L:=IF(上次G1距今天数>BARSLAST(D1),REF(L,BARSLAST(D1)),REF(L,上次G1距今天数))
G2:=G1 AND H=HHV(G1H,上次D1距今天数+1) AND H>1日前的H AND 上次D1距今天数>BARSLAST(G1)
D2:=D1 AND L=LLV(D1L,上次G1距今天数+1) AND L<1日前的L AND 上次G1距今天数>BARSLAST(D1)
G3:=G2 OR (FG0 AND REF(H,上次FG0距今天数)>REF(H,BARSLAST(G2)) AND BARSLAST(D2)>BARSLAST(G2))
D3:=D2 OR (FD0 AND REF(L,上次FD0距今天数)[BARSLAST(D2))]
如果G1X返回H否则返回DRAWNULL
如果D1X返回L否则返回DRAWNULL
{画线}
NN赋值:G3
UU赋值:D3
输出
L1:DRAWLINE(UU,L,NN, H,0),画黄色,DOTLINE
输出
L2:DRAWLINE(NN,H,UU, L,0),画白色,DOTLINE
Z1赋值:STRCAT(HYBLOCK,' ')
Z2赋值:STRCAT(Z1,DYBLOCK)
Z3赋值:STRCAT(Z2,' ')
DRAWTEXT_FIX(ISLASTBAR,0,10,0,STRCAT(Z3,GNBLOCK)),COLOR0000FF
当满足条件1时,在横轴0.00纵轴0.00位置书写文字
DRAWTEXT_FIX(1,0.07,0.00,0,EXTERNSTR(0,1))COLOR0000FF
当满足条件1时,在横轴0.00纵轴0.08位置书写文字
DRAWTEXT_FIX(1,0.07,0.08,0,EXTERNSTR(0,2))COLORFF00FF
输出
流通市值:(FINANCE(40)/100000000),NODRAW,画红色