我用BOLL指标建立交易系统,想过滤信号,避免反复开平仓的问题,比如开仓后3根K线不再做交易(不平不开),3根K线后再起作用。
用exitbars信号就消失。求教改如何修改
我的代码:
MID : MA(CLOSE,M);
UPPER: MID + N*STD(CLOSE,M);
LOWER: MID - N*STD(CLOSE,M);
//BOLL公式
cond1:=cross(c,lower) or cross(c,mid) or cross(c,upper);
//开多条件
cond2:=cross(lower,c) or cross(mid,c) or cross(upper,c);
//开空条件
if cond1 then
begin
sellshort(holding<0,0,mkt);//平空
buy(holding=0 ,2,mkt);//开多
end
if cond2 then
begin
sell(holding>0,0,mkt);//平多
buyshort(holding=0,2,mkt);//开空
end
MID := MA(CLOSE,M);
UPPER:= MID + N*STD(CLOSE,M);
LOWER:= MID - N*STD(CLOSE,M);
//BOLL公式
cond1:=cross(c,lower) or cross(c,mid) or cross(c,upper);
//开多条件
cond2:=cross(lower,c) or cross(mid,c) or cross(upper,c);
//开空条件
if cond1 and enterbars>=3 then sellshort(holding<0,0,mkt);//平空
if cond1 then buy(holding=0 ,2,mkt);//开多
if cond2 and enterbars>=3 then sell(holding>0,0,mkt);//平多
if cond2 then buyshort(holding=0,2,mkt);//开空
嗯 有了
我想问下 为什么我写成
if cond1 and enterbars>=3 then
begin
sellshort(holding<0,0,mkt);//平空
buy(holding=0 ,2,mkt);//开多
end
if cond2 and enterbars>=3 then
begin
sell(holding>0,0,mkt);//平多
buyshort(holding=0,2,mkt);//开空
end
就没有信号呢 还请前辈分析下。我想了很久逻辑上觉得没问题啊~
条件不满足,你都没开仓 哪里来的ENTERBARS