海贼西大(海米家族)
2024-12-23 11:28:02
最佳回答
通达信没有递归功能,只能自己做。我自己做的一个缠论副图公式,尚未完成,但基本功能包括k线包含,底分型,顶分型,都有了。你参考下。{每一天需要有几个参数:1、最高价,最低价,是否被前k线包含,所属走势类似(1=上升,2=下跌,3=顶分型,4=底分型,走势和分型都是最后一个k线确定,在顶底未定之前都是走势)}ma5:=ma(c,5);ma10:=ma(c,10);zb:currbarscount,nodraw;{为每根k线建立坐标}l1:= zb>1 and h<=ref(h,1) and l>=ref(l,1),nodraw;{1=当天是左包含关系}l2:= zb>2 and ref(l1,1) and h<=ref(h,2) and l>=ref(l,2),nodraw;{1=连续2天是左包含关系}l3:= zb>3 and ref(l2,1) and h<=ref(h,3) and l>=ref(l,3),nodraw;{1=连续3天是左包含关系}l4:= zb>4 and ref(l3,1) and h<=ref(h,4) and l>=ref(l,4),nodraw;{1=连续4天是左包含关系}l5:= zb>5 and ref(l4,1) and h<=ref(h,5) and l>=ref(l,5),nodraw;{1=连续5天是左包含关系}l6:= zb>6 and ref(l5,1) and h<=ref(h,6) and l>=ref(l,6),nodraw;{1=连续6天是左包含关系}l7:= zb>7 and ref(l6,1) and h<=ref(h,7) and l>=ref(l,7),nodraw;{1=连续7天是左包含关系}l8:= zb>8 and ref(l7,1) and h<=ref(h,8) and l>=ref(l,8),nodraw;{1=连续8天是左包含关系}l9:= zb>9 and ref(l8,1) and h<=ref(h,9) and l>=ref(l,9),nodraw;{1=连续9天是左包含关系}l10:= zb>10 and ref(l9,1) and h<=ref(h,10) and l>=ref(l,10),nodraw;{1=连续10天是左包含关系}lin: if(l1 or l2 or l3 or l4 or l5 or l6 or l7 or l8 or l9 or l10,1,0),nodraw; {左包含}lh: if(l10,ref(h,10),if(l9,ref(h,9),if(l8,ref(h,8),if(l7,ref(h,7),if(l6,ref(h,6),if(l5,ref(h,5),if(l4,ref(h,4),if(l3,ref(h,3),if(l2,ref(h,2),if(l1,ref(h,1),h)))))))))),nodraw;ll: if(l10,ref(l,10),if(l9,ref(l,9),if(l8,ref(l,8),if(l7,ref(l,7),if(l6,ref(l,6),if(l5,ref(l,5),if(l4,ref(l,4),if(l3,ref(l,3),if(l2,ref(l,2),if(l1,ref(l,1),l)))))))))),nodraw;r1:= if(**lastbar,0,zb>1 and h<=refx(h,1) and l>=refx(l,1)),nodraw;{1=当天是右包含关系}r2:= if(**lastbar,0,zb>2 and ref(r1,1) and h<=refx(h,1) and l>=refx(l,1)),nodraw;{1=连续2天是右包含关系}r3:= if(**lastbar,0,zb>3 and ref(r2,1) and h<=refx(h,1) and l>=refx(l,1)),nodraw;{1=连续3天是右包含关系}r4:= if(**lastbar,0,zb>4 and ref(r3,1) and h<=refx(h,1) and l>=refx(l,1)),nodraw;{1=连续4天是右包含关系}r5:= if(**lastbar,0,zb>5 and ref(r4,1) and h<=refx(h,1) and l>=refx(l,1)),nodraw;{1=连续5天是右包含关系}r6:= if(**lastbar,0,zb>6 and ref(r5,1) and h<=refx(h,1) and l>=refx(l,1)),nodraw;{1=连续6天是右包含关系}r7:= if(**lastbar,0,zb>7 and ref(r6,1) and h<=refx(h,1) and l>=refx(l,1)),nodraw;{1=连续7天是右包含关系}r8:= if(**lastbar,0,zb>8 and ref(r7,1) and h<=refx(h,1) and l>=refx(l,1)),nodraw;{1=连续8天是右包含关系}r9:= if(**lastbar,0,zb>9 and ref(r8,1) and h<=refx(h,1) and l>=refx(l,1)),nodraw;{1=连续9天是右包含关系}r10:=if(**lastbar,0,zb>10 and ref(r9,1) and h<=refx(h,1) and l>=refx(l,1)),nodraw;{1=连续10天是右包含关系}rin: if(r1 or r2 or r3 or r4 or r5 or r6 or r7 or r8 or r9 or r10,1,0),nodraw; {右包含}ld:= const(daytodate((datetoday(date)-finance(42))))+19000000,nodraw;{上市年月日}rh:= if(r10,refx(h,10),if(r9,refx(h,9),if(r8,refx(h,8),if(r7,refx(h,7),if(r6,refx(h,6),if(r5,refx(h,5),if(r4,refx(h,4),if(r3,refx(h,3),if(r2,refx(h,2),if(r1,refx(h,1),h)))))))))),nodraw;rl:= if(r10,refx(l,10),if(r9,refx(l,9),if(r8,refx(l,8),if(r7,refx(l,7),if(r6,refx(l,6),if(r5,refx(l,5),if(r4,refx(l,4),if(r3,refx(l,3),if(r2,refx(l,2),if(r1,refx(l,1),l)))))))))),nodraw;ck: not(lin or rin),nodraw;{当前k线是有效的缠论k线}ck0:=lin or rin,nodraw;cka1:= if(**lastbar,0,if(refx(ck,1),1,if(refx(ck,2),2,if(refx(ck,3),3,if(refx(ck,4),4,if(refx(ck,5),5,if(refx(ck,6),6,if(refx(ck,7),7,if(refx(ck,8),8,if(refx(ck,9),9,if(refx(ck,10),10,0))))))))))),nodraw;{后续第一根有效缠论k线到当前k线周期数} cka2:= if(**lastbar,0,cka1+refx(cka1,cka1)),nodraw;{后续第二根缠论k线到当前周期数}v1: ref(ck,1),nodraw;v2:= ref(ck0,1) and ref(ck,2),nodraw;v3:= ref(ck0,1) and ref(ck0,2) and ref(ck,3),nodraw;v4:= ref(ck0,1) and ref(ck0,2) and ref(ck0,3) and ref(ck,4),nodraw;v5:= ref(ck0,1) and ref(ck0,2) and ref(ck0,3) and ref(ck0,4) and ref(ck,5),nodraw;v6:= ref(ck0,1) and ref(ck0,2) and ref(ck0,3) and ref(ck0,4) and ref(ck0,5) and ref(ck,6),nodraw;v7:= ref(ck0,1) and ref(ck0,2) and ref(ck0,3) and ref(ck0,4) and ref(ck0,5) and ref(ck0,6) and ref(ck,7),nodraw;v8:= ref(ck0,1) and ref(ck0,2) and ref(ck0,3) and ref(ck0,4) and ref(ck0,5) and ref(ck0,6) and ref(ck0,7) and ref(ck,8),nodraw;v9:= ref(ck0,1) and ref(ck0,2) and ref(ck0,3) and ref(ck0,4) and ref(ck0,5) and ref(ck0,6) and ref(ck0,7) and ref(ck0,8) and ref(ck,9),nodraw;v10:=ref(ck0,1) and ref(ck0,2) and ref(ck0,3) and ref(ck0,4) and ref(ck0,5) and ref(ck0,6) and ref(ck0,7) and ref(ck0,8) and ref(ck0,9) and ref(ck,10),nodraw;ckb1: if(ck and v1,1,if(ck and v2,2,if(ck and v3,3,if(ck and v4,4,if(ck and v5,5,if(ck and v6,6,if(ck and v7,7,if(ck and v8,8,if(ck and v9,9,if(ck and v10,10,0)))))))))),nodraw;{前面一根有效缠论k线到当前k线周期数} ckb2:= ckb1+ref(ckb1,ckb1),nodraw;{前面第二根缠论k线到当前的周期数}upxbgn:= if(**lastbar,0,if(ck and lh<refx(lh,cka1) and refx(lh,cka1)> refx(lh,cka2),1,0)),nodraw;upxmid:= if(ck and ref(upxbgn,ckb1) and lh>ref(lh,ckb1) and lh>refx(lh,cka1),1,0),nodraw;upxend:= if(ck and ref(upxbgn,ckb2) and ref(upxmid,ckb1) and lh<ref(lh,ckb1) and ref(lh,ckb1) > ref(lh,ckb2),1,0),nodraw;dwxbgn: if(**lastbar,0,if(ck=1 and ll>refx(ll,cka1) and refx(ll,cka1)< refx(ll,cka2),1,0)),nodraw;dwxmid: if(ck and ref(dwxbgn,ckb1) and ref(ll,ckb1) >ll and ll< refx(ll,cka1),1,0),nodraw;dwxend:= if(ck and ref(dwxmid,ckb1) and ref(dwxbgn,ckb2) and ref(ll,ckb2) > ref(ll,ckb1) and ref(ll,ckb1) < ll,1,0),nodraw;upx0:= barssince(upxmid),nodraw;dwx0:= barssince(dwxmid),nodraw;x0: if(upx0>dwx0,1,0),nodraw;{x0表示该股第一次分型的类型,1表示顶分型,0表示底分型};szxbgn:= if(ck and **lastbar and h<=ref(h,1),0,if(ck and lh>ref(lh,ckb1),1,0)),nodraw;lastupx: ref(barslast(upxmid),1),nodraw;lastdwx: ref(barslast(dwxmid),1),nodraw;newupx: upxmid,nodraw;newdwx: dwxmid,nodraw;upx: ref(newupx,ckb1) and upxmid,nodraw;dwx: ref(newdwx,ckb1) and dwxmid,nodraw;stickline(lin or rin,h,l,0.8,1),colorgray;{stickline(not(lin or rin) and c>o,h,l,0.8,2),colorred;stickline(not(lin or rin) and c<o,h,l,0.8,2),colorcyan;stickline(not(lin or rin) and c=o,h,l,0.8,2),colorwhite;}stickline(not(lin or rin) ,h,l,0.8,2),colorwhite;stickline(upxmid,lh,ll,1,0),colorred;stickline(dwxmid,lh,ll,1,0),colorcyan;drawline(newupx,lh,dwxmid,ll,0),colorgreen,linethick1;drawline(newdwx,ll,upxmid,lh,0),colorgreen,linethick1; 20210311