if d then buyshort(holding=0,1,market);
if barslast(d)>0 and g then begin
sell(1,0,market);
buyshort(holding=0,1,market);
end
if d then buyshort(holding=0,1,market);
if barslast(g)>0 and g then begin
sell(1,0,market);
buyshort(holding=0,1,market);
end
这样你做个计数器
if 开仓信号 then i:=i+1;
if 开仓信号 and i=1 then buy()
然后平仓后把I清零
楼主写法没错,这是说前2次符合,这次就符合。