1.做一个调整,防止预警多品种时候会产生冲突:
[PEL] 复制代码 ma5:=ma(c,5);
ma10:=ma(c,10);
ma20:=ma(c,20);
ma30:=ma(c,30);
ma60:=ma(c,60);
l1:=min(min(min(ma10,ma20),ma30),ma60) ;
l2:=max(max(max(ma10,ma20),ma30),ma60) ;
a:ma5>l1&&(c< ref(c,1) || ref(c,1)< ref(c,2)
|| ma5<ma10 )&&(ma5>ma20 || ma5>ma60) &&(( ( l1>( l-(hhv(h,5)-l)*0.30) and ref(c,1)> ref(l1,1) )
||( l<l1 and (ref(c,1)> ref(l1,1) || c>l1)))) ;
b:ma5<l2&&(c> ref(c,1) || ref(c,1)> ref(c,2)
|| ma5>ma10 )&&(ma5<ma20 || ma5<ma60) &&(( ( l2<( h+(h-llv(l,5))*0.30) and ref(c,1)< ref(l2,1) )
||( h>l2 and (ref(c,1)< ref(l2,1) || c<l2)))) ;
sellcond:=a;
buycond:=b;
abb:time0-timetot0(dynainfo(207)),NODRAW;//K线结束倒计时 这里数值要和你选择的提前N秒保存一致
str1:STKLABEL&'t1';
str2:STKLABEL&'t2';
t1:extgbdata(str1);
t2:extgbdata(str2);
if sellcond and t1<time and abb<=5 then
begin
平预警:1;//预警条件1
extgbdataset(str1,time);
end
if buycond and t2<time and abb<=5 then
begin
开预警:1;//预警条件2
extgbdataset(str1,time);
end
2.前面策略我本地测试过 是不会在一个K上 重复触发预警。
我这里触发都是在不同的K上触发的。并且是在K结束前5秒触发的。
另外我选择的预警条件是:
如果你预警条件不对也是不行的。
|