BARSLAST函数的另类用法
标签:
股票 |
分类: 股票公式 |
{TRT -顺势交易}
variable:p1=0;
c1:=intpart(cyc(5)*100*0.96)/100;
p2:=intpart(ref(cyc(5),1)*100)/100;
p3:=intpart(ref(cyc(5),1)*0.96*100)/100;
vv:=intpart(min(capital*0.05,ref(ma(vol,34),1))/100);
p40:=intpart(maxcyc*100)/100;
p41:=intpart(ref(maxcyc,1)*100)/100;
p4:=p1=0 and c>p2 or (ref(vol/100,1)intpart(p2*0.98*100)/100 and
vol>min(capital*0.05,ref(ma(vol,34),1)));
p5:=p1=1 and c
p1:=if(p4=1,1,if(p5=1,0,ref(p1,1)));
stickline(p1=1 and c
stickline(p1=1 and c
stickline(p1=1 and c
stickline(p1=1 and c
stickline(p1=0 and c>o,c,o,8,1),colorffff54;
stickline(p1=0 and c>o,c,h,0.5,0),colorffff54;
stickline(p1=0 and c>o,l,o,0.5,0),colorffff54;
drawtext(cross(p1,0),l*0.9,'b'),coloryellow,linethick3;
drawtext(cross(1,p1),h*1.05,'s'),colorgreen,linethick3;
drawflagtext(p1=0 and (p2*0.98-c)/c>0.1,c,'持币');
drawflagtext(p1=0 and (p2*0.98-c)/c<=0.1 and
ref(vol/100,1)
drawflagtext(p1=0 and (p2*0.98-c)/c<=0.1 and
ref(vol/100,1)>=vv,c,'明日收盘价超过'+str(p2)+'买入');
drawflagtext(p1=1 and (c-min(c1,p40))/min(c1,p40)>0.1
,c,'持股');
drawflagtext(p1=1 and (c-min(c1,p40))/min(c1,p40)<=0.1
,c,'明日收盘价跌破'+str(min(c1,p40))+'卖出');;
上面是所谓大智慧正版顺势交易指标,用了循环迭代,不说这样的指标运行起来非常慢托系统,就是想转到其他软件都很困难
用基本函数BARSLAST完全可以替代上面指标中的循环迭代判断,没必要搞得那么复杂
{BARSLAST版顺势交易}
c1:=intpart(cyc(5)*100*0.96)/100;
p2:=intpart(ref(cyc(5),1)*100)/100;
p3:=intpart(ref(cyc(5),1)*0.96*100)/100;
vv:=intpart(min(capital*0.05,ref(ma(vol,34),1))/100);
p40:=intpart(maxcyc*100)/100;
p41:=intpart(ref(maxcyc,1)*100)/100;
aa:=c>p2 or (ref(vol/100,1)intpart(p2*0.98*100)/100 and
vol>min(capital*0.05,ref(ma(vol,34),1)));
bb:=c
p1:=barslast(bb)>barslast(aa);
stickline(p1=1 and c
stickline(p1=1 and c
stickline(p1=1 and c
stickline(p1=1 and c
stickline(p1=0 and c>o,c,o,8,1),colorffff54;
stickline(p1=0 and c>o,c,h,0.5,0),colorffff54;
stickline(p1=0 and c>o,l,o,0.5,0),colorffff54;
drawtext(cross(p1,0),l*0.98,'b'),coloryellow,linethick3;
drawtext(cross(1,p1),h*1.02,'s'),colorgreen,linethick3;
drawflagtext(p1=0 and (p2*0.98-c)/c>0.1,c,'持币');
drawflagtext(p1=0 and (p2*0.98-c)/c<=0.1 and
ref(vol/100,1)
drawflagtext(p1=0 and (p2*0.98-c)/c<=0.1 and
ref(vol/100,1)>=vv,c,'明日收盘价超过'+str(p2)+'买入');
drawflagtext(p1=1 and (c-min(c1,p40))/min(c1,p40)>0.1
,c,'持股');
drawflagtext(p1=1 and (c-min(c1,p40))/min(c1,p40)<=0.1
,c,'明日收盘价跌破'+str(min(c1,p40))+'卖出');;
见示意图是不是一样
另一个例子是飞狐的指标,根据三日新高新低而成的趋势指标
{原版}
input:n(3,3,9999);
x1a:=hhv(h,n);
x2a:=llv(l,n);
xc:=c;
xh:=h;
xl:=l;
for i=1 to datacount do
if xh>x1a[i-1] and xc>xc[i-1] then lya:=x2a;
else if xl
else
s3:lya,colorgreen,linethick1;
{barslast版}
input:n(3,3,9999);
hn2:=barslast(h>ref(hhv(h,n),1) and c>ref(c,1));
ln2:=barslast(l
s3:if(ln2
见示意图是不是一样
http://s7/mw690/001r6NtFgy6PxtnBIEKf6&690
通过上面2个例子可见BARSLAST函数有过滤信号的作用
再举个简单例子,突破筹码峰上沿
{突破上沿}
cross(c,ema(cost(90),8));
{用BARSLAST判断突破上沿,只取第一次}
a:=barslast(cross(c,ema(cost(90),8)));
b:=barslast(cross(c,ema(cost(10),8)));
cross(b,a);
两者比较

加载中…