通达信缠论买卖点公式 主图源码贴图

[复制链接]
查看112 | 回复0 | 2021-8-19 11:45:33 | 显示全部楼层 |阅读模式

以下是通达信缠论买卖点公式 主图源码贴图(无源码的请下载附件导入)

本帖是根据几位前辈的指标合成而成,自用方便,在此对几位前辈深表感谢!
 参数设定:0=关,1=关;
 布林 0 1 1
均线 0 1 1
三K线 0 1 1
峰谷 0 1 1
趋势 0 1 1
支压 0 1 1
参数设定上可对(布林,均线,三K线,峰谷,趋势,支压)分别开关,方便视图.
图中加入(MACD,KDJ,RSI)顶底背离仅供参考
参数设定:
布林 0 1 1
均线 0 1 1
三K线 0 1 1
峰谷 0 1 1
趋势 0 1 1
支压 0 1 1

布林:=IF(布林,1,DRAWNULL);
布林中轨 :MA(CLOSE,20)*布林,DOTLINE,COLORWHITE;
布林上轨:(布林中轨+2*STD(CLOSE,20))*布林,DOTLINE,COLORYELLOW;
布林下轨:(布林中轨-2*STD(CLOSE,20))*布林,DOTLINE,COLORMAGENTA;
DRAWBAND(布林中轨,RGB(99,00,50),布林上轨,RGB(99,00,50));
DRAWBAND(布林中轨,RGB(00,50,99),布林下轨,RGB(00,50,99));
DRAWBAND(布林中轨,RGB(99,00,50),布林上轨,RGB(99,00,50));
DRAWBAND(布林中轨,RGB(00,50,99),布林下轨,RGB(00,50,99));

均线:=IF(均线,1,DRAWNULL);
MA5:MA(C,5)*均线,COLORWHITE;
MA10:MA(C,10)*均线,COLORBLUE;

三K线:=IF(三K线,1,DRAWNULL);
DG:=MAX(MAX(REFX(L,1),REFX(L,2)),REFX(L,3));
GD:=MIN(MIN(REFX(H,1),REFX(H,2)),REFX(H,3));
AA11:=(DG+GD)/2;
A11:=AA11>REFX(L,3) AND REFX(L,2)< AA11 AND REFX(L,1) <AA11 ;
A21:=FILTER(A11,BARSLAST(A11)+2);
A41:=A11 AND A21;
A51:=IF(REF(A41,1),H,0),NODRAW;
STICKLINE(三K线=1 && REF(A41,2),REF(GD,2),REF(DG,2),13,-1),COLORWHITE;
DRAWKLINE(H,O,L,C);

{峰谷}
峰谷:=IF(峰谷,1,DRAWNULL);
PA:=10;
PB:=REF(HIGH,PA)=HHV(HIGH,2*PA+1);
PC:=FILTER(PB,PA);
PD:=BACKSET(PC,PA+1);
PE:=FILTER(PD,PA);{高点}}
峰线:(REF(HIGH,BARSLAST(PE)))*峰谷,COLORRED,POINTDOT,LINETHICK4;
AA21:=REF(LOW,PA)=LLV(LOW,2*PA+1);
BB21:=FILTER(AA21,PA);
CC21:=BACKSET(BB21,PA+1);
DD21:=FILTER(CC21,PA);{低点}
谷线:(REF(LOW,BARSLAST(DD21)))*峰谷,COLORGREEN,POINTDOT,LINETHICK4;

{趋势线}
趋势:=IF(趋势,1,DRAWNULL);
R11:=BACKSET(ISLASTBAR,BARSLAST(PE)+1);
S11:=R11>REF(R11,1);
压力轨:(DRAWLINE(PE,HIGH,S11,HIGH,1))*趋势,COLORRED;
T11:=BACKSET(ISLASTBAR,BARSLAST(DD21)+1);
U11:=T11>REF(T11,1);
支撑轨:(DRAWLINE(DD21,LOW,U11,LOW,1))*趋势,COLORGREEN;
中轨:((压力轨+支撑轨)/2)*趋势,COLORWHITE;

{支压线}
支压:=IF(支压,1,DRAWNULL);
P:=5;P1:=10;{P1、P2为短、长支撑压力取点参数}
AA1:=REF(H,P)=HHV(H,2*P+1);
BB1:=FILTER(AA1,P);
CC1:=BACKSET(BB1,P+1);
DD1:=FILTER(CC1,P);
EE1:=BACKSET(ISLASTBAR,BARSLAST(DD1)+1);
FF1:=EE1>REF(EE1,1);
短压:(DRAWLINE(DD1,H,FF1,H,1))*支压,COLORLIRED;
短压线:(DRAWICON(FF1,H*1,2))*支压;
AA2:=REF(L,P)=LLV(L,2*P+1);
BB2:=FILTER(AA2,P);
CC2:=BACKSET(BB2,P+1);
DD2:=FILTER(CC2,P);
EE2:=BACKSET(ISLASTBAR,BARSLAST(DD2)+1);
FF2:=EE2>REF(EE2,1);
短支:(DRAWLINE(DD2,L,FF2,L,1))*支压,COLORLIGREEN;
短支线:(DRAWICON(FF2,L*1,1))*支压;

{三角形中枢}
时间:=4;
A:=H=HHV(H,时间*5) AND HHV(H,时间*5)>REF(HHV(H,时间*5),1);
B:=L=LLV(L,时间*5) AND LLV(L,时间*5)<REF(LLV(L,时间*5),1);
CCA:DRAWLINE(A,H,B,L,0),COLORYELLOW,LINETHICK2;
CCB:DRAWLINE(B,L,A,H,0),COLORMAGENTA,LINETHICK2;
N:=(0,1,1);
{缠论高低点}
局部低点预选A:=BACKSET(LLV(L,5)<REF(LLV(L,4),1),4);
局部低点预选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,5)>REF(HHV(H,4),1),4);
局部高点预选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;
C1:DRAWLINE(极点保留=-1,局部极点,极点保留=1,局部极点,0),COLORMAGENTA,DOTLINE;
C2:DRAWLINE(极点保留=1,局部极点,极点保留=-1,局部极点,0),COLORYELLOW,DOTLINE;
DRAWTEXT(极点保留=1,局部极点,'卖'),COLORGREEN;
DRAWTEXT(极点保留=-1,局部极点,'买'),COLORRED;

{顶底背离}
LC:=REF(CLOSE,1);
RSI:=((SMA(MAX((CLOSE - LC),0),3,1) / SMA(ABS((CLOSE - LC)),3,1)) * 100);
FF:=EMA(CLOSE,3);
MA15:=EMA(CLOSE,21);
DRAWTEXT(CROSS(FF,MA15),(LOW *0.999),'底背离'),COLORRED;
{顶背离}
RSI1:=((SMA(MAX((CLOSE - (REF(CLOSE,1))),0),3,1) / SMA(ABS((CLOSE - (REF(CLOSE,1)))),3,1))* 100);
DRAWTEXT(CROSS(88,RSI1) AND  (MA(C,3))>(EMA(C,3)) ,(HIGH *1.001),'顶背离'),COLORGREEN;
DRAWTEXT(REF(C,BARSLAST(REF(CROSS("MACD.DIF","MACD.DEA"),1))+1)>C AND
REF("MACD.DIF",BARSLAST(REF(CROSS("MACD.DIF","MACD.DEA"),1))+1)
<"MACD.DIF" AND CROSS("MACD.DIF","MACD.DEA")
>0,L-0.002,'MACD底背离'),COLORRED;{MACD底背离}
DRAWTEXT(REF(C,BARSLAST(REF(CROSS("KDJ.K","KDJ.D"),1))+1)>C AND
REF("KDJ.K",BARSLAST(REF(CROSS("KDJ.K","KDJ.D"),1))+1)<"KDJ.K" AND
CROSS("KDJ.K","KDJ.D"),L-0.003,'KDJ底背离'),COLORBLUE;{KDJ底背离}
DRAWTEXT(REF(C,BARSLAST(REF(CROSS("RSI.RSI1","RSI.RSI2"),1))+1)>C AND
REF("RSI.RSI1",BARSLAST(REF(CROSS("RSI.RSI1","RSI.RSI2"),1))+1)
<"RSI.RSI1" AND CROSS("RSI.RSI1","RSI.RSI2")
>0,L-0.004,'RSI底背离');{RSI底背离};
DRAWTEXT(REF(C,BARSLAST(REF(CROSS("MACD.DEA","MACD.DIF"),1))+1)<C
AND REF("MACD.DIF",BARSLAST(REF(CROSS("MACD.DEA","MACD.DIF"),1))+1)
>"MACD.DIF" AND CROSS("MACD.DEA","MACD.DIF")
>0,H+0.002,'MACD顶背离'),COLORGREEN;{MACD顶背离};
DRAWTEXT(REF(C,BARSLAST(REF(CROSS("KDJ.D","KDJ.K"),1))+1)<C
AND REF("KDJ.K",BARSLAST(REF(CROSS("KDJ.D","KDJ.K"),1))+1)
>"KDJ.K" AND CROSS("KDJ.D","KDJ.K")>0,H+0.003,'KDJ顶背离');{KDJ顶背离};


 

936344853.png

936344853.png

回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则