通达信公式(通达信主图公式)
消息里一直有朋友在问是否可以分享缠论画笔的源码。现分享出来,并且在里面加入了时间周期和换手率。但是缠论博大精深,目前市场上也没有能精确表达的源码,此源码缺点明显,仅供缠论爱好者研究。
缠论画笔源码
N:=5,100,10;
振幅:=0,1,1;
统计:=0,1,1;
局部低点预选A:=BACKSET(LLV(L,10*N)<REF(LLV(L,10*N-1),1),10*N-1);
局部低点预选B:=BACKSET(局部低点预选A=0 AND REF(局部低点预选A,1)=1,2);
局部低点预选C:=IF(局部低点预选B=1 AND REF(局部低点预选B,1)=0,-1,0);
局部高点预选A:=BACKSET(HHV(H,10*N)>REF(HHV(H,10*N-1),1),10*N-1);
局部高点预选B:=BACKSET(局部高点预选A=0 AND REF(局部高点预选A,1)=1,2);
局部高点预选C:=IF(局部高点预选B=1 AND REF(局部高点预选B,1)=0,1,0);
缺口判断:=IF(L>REF(H,1),1,IF(H<REF(L,1),-1,0));
距前高天:=BARSLAST(局部高点预选C=1);
距前低天:=BARSLAST(局部低点预选C=-1);
小值周期:=LOWRANGE(L);
大值周期:=TOPRANGE(H);
低保留AA:=IF(局部低点预选C=-1 AND REF(距前高天,1)>REF(距前低天,1) AND LLV(L,距前高天+1)<REF(LLV(L,距前高天+1),1),-1,0);
低保留AB:=IF(局部低点预选C=-1 AND REF(距前高天,1)<=REF(距前低天,1) AND (距前高天>=4 OR LLV(缺口判断,距前高天)=-1 OR LLV(L,距前低天+2)<REF(LLV(L,距前低天+1),1)),-1,0);
低保留S:=IF((低保留AA=-1 OR 低保留AB=-1) AND L<REF(H,距前高天+1),-1,0);
预判:=IF((距前低天<4 AND HHV(缺口判断,距前低天)!=1) OR REF(低保留S,距前低天)=0,1,0);
判断:=IF(局部高点预选C=1 AND REF(距前低天,1)<=REF(距前高天,1) AND 预判=1 AND 大值周期>REF(小值周期,距前低天+1) AND 大值周期>REF(小值周期,距前低天) AND 大值周期>REF(大值周期,距前高天),1,0);
高保留A:=IF(局部高点预选C=1 AND REF(距前低天,1)>REF(距前高天,1) AND HHV(H,距前低天+1)>REF(HHV(H,距前低天+1),1),1,0);
高保留B:=IF(局部高点预选C=1 AND REF(距前低天,1)<=REF(距前高天,1) AND REF(低保留S,距前低天)=-1 AND (距前低天>=4 OR HHV(缺口判断,距前低天)=1),1,0);
高保留:=IF((高保留A=1 OR 高保留B=1 OR 判断=1) AND H>REF(L,距前低天+1),1,0);
预判A:=IF((距前高天<4 AND HHV(缺口判断,距前高天)!=1) OR REF(高保留,距前高天)=0,1,0);
判断A:=IF(局部低点预选C=-1 AND REF(距前高天,1)<=REF(距前低天,1) AND 预判A=1 AND 小值周期>REF(大值周期,距前高天+1) AND 小值周期>REF(大值周期,距前高天) AND 小值周期>REF(小值周期,距前低天),-1,0);
低保留A:=IF(局部低点预选C=-1 AND REF(距前高天,1)>REF(距前低天,1) AND LLV(L,距前高天+1)<REF(LLV(L,距前高天+1),1),-1,0);
低保留B:=IF(局部低点预选C=-1 AND REF(距前高天,1)<=REF(距前低天,1) AND (距前高天>=4 OR LLV(缺口判断,距前高天)=-1 OR 判断A=-1),-1,0);
低保留:=IF((低保留A=-1 OR 低保留B=-1) AND L<REF(H,距前高天+1),-1,0);
距前高天A:=BARSLAST(高保留=1);
距前低天A:=BARSLAST(低保留=-1);
预判X:=IF((距前低天A<4 AND HHV(缺口判断,距前低天A)!=1) OR REF(低保留,距前低天A)=0,1,0);
判断X:=IF(局部高点预选C=1 AND REF(距前低天A,1)<=REF(距前高天A,1) AND 预判X=1 AND 大值周期>REF(小值周期,距前低天A+1) AND 大值周期>REF(小值周期,距前低天A) AND 大值周期>REF(大值周期,距前高天A),1,0);
高保留XA:=IF(局部高点预选C=1 AND REF(距前低天A,1)>REF(距前高天A,1) AND HHV(H,距前低天A+1)>REF(HHV(H,距前低天A+1),1),1,0);
高保留XB:=IF(局部高点预选C=1 AND REF(距前低天A,1)<=REF(距前高天A,1) AND REF(低保留,距前低天A)=-1 AND (距前低天A>=4 OR HHV(缺口判断,距前低天A)=1),1,0);
高保留X:=IF((高保留XA=1 OR 高保留XB=1 OR 判断X=1) AND H>REF(L,距前低天A+1),1,0);
预判XA:=IF((距前高天A<4 AND HHV(缺口判断,距前高天A)!=1) OR REF(高保留XA,距前高天A)=0,1,0);
判断XA:=IF(局部低点预选C=-1 AND REF(距前高天A,1)<=REF(距前低天A,1) AND 预判XA=1 AND 小值周期>REF(大值周期,距前高天A+1) AND 小值周期>REF(大值周期,距前高天A) AND 小值周期>REF(小值周期,距前低天A),-1,0);
低保留XA:=IF(局部低点预选C=-1 AND REF(距前高天A,1)>REF(距前低天A,1) AND LLV(L,距前高天A+1)<REF(LLV(L,距前高天A+1),1),-1,0);
低保留XB:=IF(局部低点预选C=-1 AND REF(距前高天A,1)<=REF(距前低天A,1) AND (距前高天A>=4 OR LLV(缺口判断,距前高天A)=-1 OR 判断XA=-1),-1,0);
低保留X:=IF((低保留XA=-1 OR 低保留XB=-1) AND L<REF(H,距前高天A+1),-1,0);
距前高天YA:=BARSLAST(高保留X=1);
距前低天YA:=BARSLAST(低保留X=-1);
预判YX:=IF((距前低天YA<4 AND HHV(缺口判断,距前低天YA)!=1) OR REF(低保留X,距前低天YA)=0,1,0);
判断YX:=IF(局部高点预选C=1 AND REF(距前低天YA,1)<=REF(距前高天YA,1) AND 预判YX=1 AND 大值周期>REF(小值周期,距前低天YA+1) AND 大值周期>REF(小值周期,距前低天YA) AND 大值周期>REF(大值周期,距前高天YA),1,0);
高保留YXA:=IF(局部高点预选C=1 AND REF(距前低天YA,1)>REF(距前高天YA,1) AND HHV(H,距前低天YA+1)>REF(HHV(H,距前低天YA+1),1),1,0);
高保留YXB:=IF(局部高点预选C=1 AND REF(距前低天YA,1)<=REF(距前高天YA,1) AND REF(低保留X,距前低天YA)=-1 AND (距前低天YA>=4 OR HHV(缺口判断,距前低天YA)=1),1,0);
高保留YX:=IF((高保留YXA=1 OR 高保留YXB=1 OR 判断YX=1) AND H>REF(L,距前低天YA+1),1,0);
预判YXA:=IF((距前高天YA<4 AND HHV(缺口判断,距前高天YA)!=1) OR REF(高保留YXA,距前高天YA)=0,1,0);
判断YXA:=IF(局部低点预选C=-1 AND REF(距前高天YA,1)<=REF(距前低天YA,1) AND 预判YXA=1 AND 小值周期>REF(大值周期,距前高天YA+1) AND 小值周期>REF(大值周期,距前高天YA) AND 小值周期>REF(小值周期,距前低天YA),-1,0);
低保留YXA:=IF(局部低点预选C=-1 AND REF(距前高天YA,1)>REF(距前低天YA,1) AND LLV(L,距前高天YA+1)<REF(LLV(L,距前高天YA+1),1),-1,0);
低保留YXB:=IF(局部低点预选C=-1 AND REF(距前高天YA,1)<=REF(距前低天YA,1) AND (距前高天YA>=4 OR LLV(缺口判断,距前高天YA)=-1 OR 判断YXA=-1),-1,0);
低保留YX:=IF((低保留YXA=-1 OR 低保留YXB=-1) AND L<REF(H,距前高天YA+1),-1,0);
AAAD:=IF(高保留YX=1 AND 低保留YX=-1 AND H>REF(H,REF(距前高天YA,1)+2),1,IF(高保留YX=1 AND 低保留YX=-1 AND L<REF(L,REF(距前低天YA,1)+2),-1,0));
极点保留:=IF(AAAD=0,高保留YX+低保留YX,AAAD);
极点:IF(极点保留=-1,L,IF(极点保留=1,H,DRAWNULL)),CIRCLEDOT,COLORLIMAGENTA;
顶周期:=N*10;
底周期:=N*10;
上内:=LLVBARS(H,顶周期);
上外:=LLVBARS(L,顶周期);
下内:=HHVBARS(L,底周期);
下外:=HHVBARS(H,底周期);
上力度:=HHV(L,上内+1)>LLV(H,上内+1);
下力度:=HHV(L,下内+1)>LLV(H,下内+1);
上包含:=COUNT(L>=REF(L,1),上外)>2 AND COUNT(H>=REF(H,1),上内)>2;
下包含:=COUNT(H<=REF(H,1),下外)>2 AND COUNT(L<=REF(L,1),下内)>2;
顶A:=顶周期 AND 上力度 AND 上包含 AND 上外>3;
底B:=底周期 AND 下力度 AND 下包含 AND 下外>3;
顶:=顶A AND H=HHV(H,BARSLAST(底B))AND BARSLAST(底B)>3;
底:=底B AND L=LLV(L,BARSLAST(顶A))AND BARSLAST(顶A)>3;
C1:=DRAWLINE(顶,H,底,L,0);
C2:=DRAWLINE(底,L,顶,H,0);
GD:=C2=C1 AND 顶;
DD:=C2=C1 AND 底;
CC:=DD OR GD;
变点:IF(DD=1,L,IF(GD=1,H,DRAWNULL)),CIRCLEDOT,COLORYELLOW;
交易周期:BARSLAST(CC)+1,NODRAW;
区间成交额:SUM(AMO.AMOW/10000,交易周期),NODRAW;{亿}
区间换手:IF(CC=0,SUM(HSL.HSL,交易周期),0),COLORRED,NODRAW;{%}
区间涨幅:C/REF(C,交易周期)*100-100,NODRAW,COLORWHITE;{%}
高点换手:=VARCAT(VARCAT(\\\'换\\\',VAR2STR(SUM(HSL.HSL,BARSLAST(GD)+1),2)),\\\'%\\\');
低点换手:=VARCAT(VARCAT(\\\'换\\\',VAR2STR(SUM(HSL.HSL,BARSLAST(DD)+1),2)),\\\'%\\\');
区间振幅:IF(GD>0,-(REF(H,BARSLAST(GD))/L*100-100),H/REF(L,BARSLAST(DD))*100-100),COLORYELLOW,NODRAW;
高跌幅A:=IF(振幅=1,-(REF(H,BARSLAST(GD))/L*100-100),C/REF(C,BARSLAST(GD)+1)*100-100);
低涨幅A:=IF(振幅=1,H/REF(L,BARSLAST(DD))*100-100,C/REF(C,BARSLAST(DD)+1)*100-100);
高跌幅:=IF(振幅=1,VARCAT(VARCAT(\\\'振\\\',VAR2STR(高跌幅A,2)),\\\'%\\\'),VARCAT(VARCAT(\\\'幅\\\',VAR2STR(高跌幅A,2)),\\\'%\\\'));
低涨幅:=IF(振幅=1,VARCAT(VARCAT(\\\'振\\\',VAR2STR(低涨幅A,2)),\\\'%\\\'),VARCAT(VARCAT(\\\'幅\\\',VAR2STR(低涨幅A,2)),\\\'%\\\'));
高点时间:=VARCAT(VARCAT(\\\'交易\\\',VAR2STR(BARSLAST(GD)+1,0)),\\\'天\\\');
低点时间:=VARCAT(VARCAT(\\\'交易\\\',VAR2STR(BARSLAST(DD)+1,0)),\\\'天\\\');
星期:=VARCAT(VARCAT(\\\'(\\\',IF(WEEKDAY=1,\\\'一\\\',IF(WEEKDAY=2,\\\'二\\\',IF(WEEKDAY=3,\\\'三\\\',IF(WEEKDAY=4,\\\'四\\\',IF(WEEKDAY=5,\\\'五\\\',\\\'\\\')))))),\\\')\\\');
日期:=VARCAT(VARCAT(VARCAT(VARCAT(VARCAT(VARCAT(VAR2STR(YEAR,0),\\\'年\\\'),VAR2STR(MONTH,0)),\\\'月\\\'),VAR2STR(DAY,0)),\\\'日\\\'),星期);
价格:=VARCAT(VAR2STR(极点,2),\\\'元\\\');
日期价格:=VARCAT(日期,价格);
高点显示:=VARCAT(VARCAT(低点时间,低涨幅),低点换手);
低点显示:=VARCAT(VARCAT(高点时间,高跌幅),高点换手);
ST:=NAMELIKE(\\\'ST\\\')=1 OR NAMELIKE(\\\'*ST\\\')=1 OR NAMELIKE(\\\'SST\\\')=1 OR NAMELIKE(\\\'S*ST\\\')=1 OR NAMELIKE(\\\'S ST\\\')=1;
明涨停:IF(ST=1,ZTPRICE(C,0.05),ZTPRICE(C,0.1)),COLORRED,NODRAW;
明跌停:IF(ST=1,DTPRICE(C,0.05),DTPRICE(C,0.1)),COLORGREEN,NODRAW;
DRAWBAND(C1,RGB(0,0,0),C1,RGB(0,0,0)),COLORGREEN,DOTLINE;
DRAWBAND(C2,RGB(0,0,0),C2,RGB(0,0,0)),COLORRED,DOTLINE;
DRAWTEXT(GD=1 AND 统计=1 ,H,高点显示),DRAWABOVE,COLORRED;
DRAWTEXT(DD=1 AND 统计=1 ,L,低点显示),DRAWABOVE,COLORGREEN;
DRAWTEXT(GD=1 AND 统计=1 ,H*0.93,日期价格),DRAWABOVE;
DRAWTEXT(DD=1 AND 统计=1 ,L,日期价格);