我想编写
一个完整交易日内(包括夜盘),多头止损后价格再次突破30周期高点继续买开,如再次止损后 当天不再交易。
一个完整交易日内(包括夜盘),空头止损后价格再次跌破20周期低点继续卖开,如再次止损后 当天不再交易。
但编写如下,为什么不能过滤呢?每天还开2次以上。
VARIABLE:mark=0;
VARIABLE:mark2=0;
atrx:=2;
手数:=1;
hh:hhv(ref(h,1),30);
ll:llv(ref(l,1),20);
aa:BARSLAST(c>hh and holding=0)+1;
bb:BARSLAST(c<ll and holding=0)+1;
TR1:=MAX(MAX((HIGH-LOW),ABS(REF(CLOSE,1)-HIGH)),ABS(REF(CLOSE,1)-LOW));
ATR:=MA(TR1,14);
zhis1:=ref(low,aa)>low and holding>0;
zhis2:=ref(h,aa)<h and holding<0;
if ref(low,aa)>low and holding>0 then sell(1,holding,LIMIT,c);
if ref(h,aa)<h and holding<0 then SELLSHORT(1,holding,LIMIT,c);
tq:=3;
abb:=(time0-TIMETOT0(DYNAINFO(207))<=tq) or not(ISLASTBAR);
zhiy1:(AVGENTERPRICE-c)>ATR*atrx and HOLDING<0;
zhiy2:(C-AVGENTERPRICE)>ATR*atrx and HOLDING>0;
平空:SELLSHORT((AVGENTERPRICE-c)>ATR*atrx and HOLDING<0,手数,MARKET);
平多:SELL((C-AVGENTERPRICE)>ATR*atrx and HOLDING>0,手数,MARKET);
//主要看这里一下部分
if ref(low,aa)>low and holding>0 then
begin
mark:=mark+1;
end
if c>=hh and holding=0 and mark<=2 then
begin
开多:BUY(c>=hh and holding=0,手数,MARKET);
end
if time>=closetime(0) then mark:=0;
if ref(h,aa)<h and holding<0 then
begin
mark2:=mark2+1;
end
if c<=ll and holding=0 and mark<=2 then
begin
开空:BUYSHORT(c<=ll and holding=0,手数,MARKET);
end
if time>=closetime(0) then mark2:=0;