大智慧引用函数filter,sumbars运用 1,函数:filter 信号过滤 过滤连续出现的信号. 用法:filter(x,n),x满足条件后,删除其后n周期内的数据置为0. 例如:filter(closeopen,5),查找阳线,5天内再次出现的阳线不被记录在内.请看下面指标: 顶底背离:0,coloryellow; a1:=barslast(ref(cross("macd.diff"(12,26,9),"macd.dea"(12,26,9)),1)); b1:=ref(c,a1+1)c and ref("macd.diff"(12,26,9),a1+1)"macd.diff"(12,26,9) and cross("macd.diff"(12,26,9),"macd.dea"(12,26,9)); } drawtext(filter(b10,5),0.57,"macd底背离"),color00ff00; a2:=barslast(ref(cross("kdj.k"(9,3,3),"kdj.d"(9,3,3)),1)); b2:=ref(c,a2+1)c and ref("kdj.k"(9,3,3),a2+1)"kdj.k"(9,3,3) and cross("kdj.k"(9,3,3),"kdj.d"(9,3,3)); } drawtext(filter(b20,5),0.80,"kdj底背离"),coloryellow; a3:=barslast(ref(cross("rsi.rsi1"(6,12,24),"rsi.rsi2"(6,12,24)),1)); b3:=ref(c,a3+1)c and ref("rsi.rsi1"(6,12,24),a3+1)"rsi.rsi1"(6,12,24) and cross("rsi.rsi1"(6,12,24),"rsi.rsi2"(6,12,24)); } drawtext(filter(b30,5),0.25,"rsi底背离"),colorffcc66; 2,colorred; c1:=barslast(ref(cross("macd.dea"(12,26,9),"macd.diff"(12,26,9)),1)); d1:=ref(c,c1+1)c and ref("macd.diff"(12,26,9),c1+1)"macd.diff"(12,26,9) and cross("macd.dea"(12,26,9),"macd.diff"(12,26,9)); } drawtext(filter(d10,5),1.47,"macd顶背离"),color0066ff; c2:=barslast(ref(cross("kdj.d"(9,3,3),"kdj.k"(9,3,3)),1)); d2:=ref(c,c2+1)c and ref("kdj.k"(9,3,3),c2+1)"kdj.k"(9,3,3) and cross("kdj.d"(9,3,3),"kdj.k"(9,3,3)); } drawtext(filter(d20,5),1.2,"kdj顶背离"),colorred; c3:=barslast(ref(cross("rsi.rsi2"(6,12,24),"rsi.rsi1"(6,12,24)),1)); d3:=ref(c,c3+1)c and ref("rsi.rsi1"(6,12,24),c3+1)"rsi.rsi1"(6,12,24) and cross("rsi.rsi2"(6,12,24),"rsi.rsi1"(6,12,24)); } drawtext(filter(d30,5),1.75,"rsi顶背离"),colorff00ff; 这是一个引用filter函数比较多的指标,请认真研究和体会一下语句的用法. 2,函数:sumbars 累加到指定周期数 向前累加到指定值到现在的周期数. 用法:sumbars(x,a),将x向前累加直到大于等于a,返回这个区间的周期数. 例如:sumbars(vol,capital),求完全换手到现在的周期数. 这个函数好用,在于它不但能精确地得到统计结果,而且能得到"模糊"的结果. 就以sumbars(vol,capital)为例: 日期数:sumbars(vol,capital);{返回成交量累加到流通盘的日期数} 验证:sum(v,日期数)capital;{把返回的日期数之内的成交量累计,再除以流通盘} 运行的结果中,我们可以看到,"验证"的输出,除了sumbars起算点附近之外,从来没有小于1的.可见sumbars只往多算,不往少算.请看下面指标: var1:=(close-llv(low,45))(hhv(high,45)-llv(low,45))*100; var2:=sma(var1,3,1); var3:=sma(var2,3,1); varb:=sum(if(closeref(close,7),vol,if(closeref(close,7),0-vol,0)),0); varc:=sumbars(vol,capital);{求完全换手到现在的周期数} vard:=if(closellv(close,varc),1,-1); vare:=if(varbllv(varb,varc),1,-1); varf:=vard*vare; var10:=if(varf=-1,1,0); 关注:if(var10 and close=llv(close,20) and var312,70,1),colorffcc66;{在图上0--70的坐标处显示青色脉冲信号} v1:=sum(if(closeref(close,1),vol,if(closeref(close,1),0-vol,0)),0); v2:=sumbars(vol,capital);{求完全换手到现在的周期数} v3:=if(closellv(close,v2),1,-1); v4:=if(v1llv(v1,v2),1,-1); v5:=v3*v4; v6:=if(v5=-1,1,0); v7:=count(v6=1,8)2; v8:=amountvol100; v9:=(3*high+low+open+2*close)7; va:=sum(amount,13)v8100; vb:=dma(v9,volva); vc:=(close-vb)vb*100-15; vd:=(close-min(ref(close,5)*0.865,ref(close,21)*0.772))close0.05; 长针:(vc and vd and v7)*60,coloryellow;