原文地址:缠论公式_通达信作者:好过些博主 {悟多版缠论} { n1:=10;n2:=10;disp:=2; k:=if(period=5,1,{日} if(period=6,1,{周} if(period=7,1,{月} if(period=8,1,{多分钟} if(period=9,1,{多日} if(period=10,1,{季} if(period=11,2,{年} if(period=4,1,{60f} if(period=3,1,{30f} if(period=2,1,{15f} if(period=1,1{5f},1{1f}))10; p1:=peak(1,k*n1,1); p2:=peak(1,k*n1,2); wp1:=peakbars(1,k*n1,1); wp2:=peakbars(1,k*n1,2); t1:=trough(2,k*n2,1); t2:=trough(2,k*n2,2); wt1:=troughbars(2,k*n2,1); wt2:=troughbars(2,k*n2,2); tj1:=p1t1 and p2t2 ; zd:=max(t1,t2); zg:=min(p1,p2); ll:=min(t1,t2); hh:=max(p1,p2); tj2:=filter(zgzd,2); tj3:=zg=ref(zg,barslast(tj2)) or zd=ref(zd,barslast(tj2)); tj4:=tj1&&tj2&&not(tj3); tj5:=between(zd,ref(zd,ref(barslast(tj4),1)),ref(zg,ref(barslast(tj4),1; tj6:=between(zg,ref(zd,ref(barslast(tj4),1)),ref(zg,ref(barslast(tj4),1; tj7:=zgref(zg,ref(barslast(tj4),1))&&zd tj8:=tj4&&not(tj5 or tj6 or tj7); zsd:=if(tj8,zd,drawnull); zsg:=if(tj8,zg,drawnull); zsh:=if(tj8,hh,drawnull); zsl:=if(tj8,ll,drawnull); stickline(tj8,zsh,zsl,0,-1),colormagenta; stickline(tj8,zsd,zsg,if(disp=1,3,0),1),colormagenta; drawtext(disp=2,zsh, 中枢 ),colorred; 中枢高:ployline(disp=2,ref(zsd,barslast(tj8,crossdot,colorlired; 中枢低:ployline(disp=2,ref(zsg,barslast(tj8,crossdot,colorligreen; 中枢最高:ployline(disp=2,ref(zsh,barslast(tj8,pointdot,colorred; 中枢最低:ployline(disp=2,ref(zsl,barslast(tj8,pointdot,colorgreen; 趋势高:ployline(disp=3,zig(1,k*n1)),colorliblue; 趋势低:ployline(disp=3,zig(2,k*n2)),colorliblue; 局部低点预选a:=backset(llv(l,5) 局部低点预选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(lref(h,1),1,if(h 距前高天:=barslast(局部高点预选c=1); 距前低天:=barslast(局部低点预选c=-1); 小值周期:=lowrange(l); 大值周期:=toprange(h); 低保留aa:=if(局部低点预选c=-1 and ref(距前高天,1)ref(距前低天,1) and llv(l,距前高天+1) 低保留ab:=if(局部低点预选c=-1 and ref(距前高天,1)=ref(距前低天,1) and (距前高天=4 or llv(缺口判断,距前高天)=-1 or llv(l,距前低天+2) 低保留s:=if((低保留aa=-1 or 低保留ab=-1) and l 预判:=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 href(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) 低保留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 距前高天a:=barslast(高保留=1); 距前低天a:=barslast(低保留=-1); 预判x:=if((距前低天a4 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 href(l,距前低天a+1),1,0); 预判xa:=if((距前高天a4 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) 低保留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 距前高天ya:=barslast(高保留x=1); 距前低天ya:=barslast(低保留x=-1); 预判yx:=if((距前低天ya4 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 href(l,距前低天ya+1),1,0); 预判yxa:=if((距前高天ya4 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) 低保留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 aaad:=if(高保留yx=1 and 低保留yx=-1 and href(h,ref(距前高天ya,1)+2),1,if(高保留yx=1 and 低保留yx=-1 and l 极点保留:=if(aaad=0,高保留yx+低保留yx,aaad); 局部极点:if(极点保留=-1,l,if(极点保留=1,h,drawnull)) circledot coloryellow; drawline(极点保留=-1,局部极点,极点保留=1,局部极点,0)colorlired; drawline(极点保留=1,局部极点,极点保留=-1,局部极点,0)coloryellow; dd1:=barslast(abs(极点保留)!=1); drawtext(极点保留=1,局部极点, * ),colorgreen; drawtext(极点保留=-1,局部极点, * ),colorred; (ma5 {笔底分型__ 确保向下笔成立后的底分型} 重心线:(h+l+o+c*3)6; nx:=(3*close+low+open+high)6; 牛线:=(20*nx+19*ref(nx,1)+18*ref(nx,2)+17*ref(nx,3)+16*ref(nx,4) +15*ref(nx,5)+14*ref(nx,6)+13*ref(nx,7)+12*ref(nx,8)+11*ref(nx,9) +10*ref(nx,10)+9*ref(nx,11)+8*ref(nx,12)+7*ref(nx,13)+6*ref(nx,14) +5*ref(nx,15)+4*ref(nx,16)+3*ref(nx,17) +2*ref(nx,18)+ref(nx,20))210; 牛熊线:ma(牛线,6),colorgreen,linethick2; 简底:=href(h,1) and ref(h,1)ref(l,1) and ref(l,1) 简顶:=href(h,2) and lref(l,2); 包含1:=ref(h,1)=ref(h,2) and ref(l,1)=ref(l,2); 包含2:=ref(h,1)=ref(h,2) and ref(l,1)=ref(l,2); 包底1:=href(h,2) and ref(h,2)ref(l,1) and ref(l,1) 包底2:=href(h,1) and ref(h,1)ref(l,2) and ref(l,2) 包顶1:=href(h,3) and lref(l,3); 包顶2:=href(h,3) and lref(l,3); 复底:=if(包含1,包底1,if(包含2,包底2,简底)); 复顶:=if(包含1,包顶1,if(包含2,包顶2,简顶)); 底分型:=if(barslast(cross(牛熊线,重心线))3,filter(backset(filter(复底 and 重心线牛熊线,3),2),1),0); 顶分型:=if(barslast(cross(重心线,牛熊线))3,filter(backset(filter(复顶 and 重心线牛熊线,3),2),1),0); stickline(底分型,c,o,8,0),colorff00ff,linethick2; stickline(底分型,c,o,3,0),colorff00ff,linethick2; stickline(底分型,h,l,1,0),colorff00ff,linethick2; stickline(顶分型,c,o,8,0),coloryellow,linethick2; stickline(顶分型,c,o,3,0),coloryellow,linethick2; stickline(顶分型,h,l,1,0),coloryellow,linethick2; drawtext(底分型,l*0.99, 底型 ),coloryellow,linethick1; drawtext(顶分型,h*1.02, 顶型 ),coloryellow,linethick1; {nczs 4.0_缠中说禅走势} {名称:nczs 4.0} {描述:缠中说禅走势} {功能:图解市场一二三类买卖点} {设计:股市肉鸡} {版本:4.00} {日期:2010.02.22} {参数:short 5307 long 1025019} t:=period; d:=if(t=0,30,if(t=1,25,if(t=8,25,if(t=2,20,if(t=3,20,if(t=4,20,if(t=5,10,if(t=6,10,if(t=7,10,if(t=9,10,if(t=10,10,10)); rma:=ema(close,short); nma:=ema(close,long); (l=llv(l,barslast(cross(nma,rma))+1) and l=llv(l,d) and rma=nma,l,h=hhv(h,barslast(cross(rma,nma))+1) and h=hhv(h,d) and rma=nma,h,0),colorwhite; (h=hhv(h,barslast(cross(rma,nma))+1) and h=hhv(h,d) and rma=nma,h,l=llv(l,barslast(cross(nma,rma))+1) and l=llv(l,d) and rma=nma,l,0),colorwhite; {布林+顶底线段} 布林中线:ma(close,21); 布林上线:布林中线+2*std(close,21) colorgreen; 布林下线:布林中线-2*std(close,21) colorred; 局部低点预选a:=backset(llv(l,5) 局部低点预选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); 局部极点a:=局部低点预选c+局部高点预选c;  circledot coloryellow; 缺口判断:=if(lref(h,1),1,if(h 距前高天:=barslast(局部高点预选c=1); 距前低天:=barslast(局部低点预选c=-1); 小值周期:=lowrange(l); 大值周期:=toprange(h); 低保留aa:=if(局部低点预选c=-1 and ref(距前高天,1)ref(距前低天,1) and llv(l,距前高天+1) 低保留ab:=if(局部低点预选c=-1 and ref(距前高天,1)=ref(距前低天,1) and (距前高天=4 or llv(缺口判断,距前高天)=-1 or llv(l,距前低天+2) 低保留s:=if((低保留aa=-1 or 低保留ab=-1) and l 预判:=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 href(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) 低保留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 aaad:=if(高保留=1 and 低保留=-1 and href(h,ref(距前高天,1)+2),1,if(高保留=1 and 低保留=-1 and l 极点保留:=if(aaad=0,高保留+低保留,aaad); 局部极点:=if(极点保留=-1,l,if(极点保留=1,h,drawnull)) circledot coloryellow; drawline(极点保留=-1,局部极点,极点保留=1,局部极点,0)colorblue; drawline(极点保留=1,局部极点,极点保留=-1,局部极点,0)colorblue;