比如:diff 和dea >0 轴,平空开多。小于0轴,平多开空。会出现条件满足,一直开仓。如何解决开仓后一直持仓待下一信号出现,而不是一直开仓。
diff:="macd.diff";
dea:="macd.dea";
Long:diff >=0 and dea >=0;
if Long then begin
sellshort(holding<0,holding,market);
buy(1,1,market);
end
short:diff<=0 and dea<=0;
if short then begin
sell(holding>0,holding,market);
buyshort(1,1,market);
end
[此贴子已经被作者于2017/5/10 19:31:17编辑过]
突然反应过来,知道咋做了
diff:="macd.diff";
dea:="macd.dea";
Long:diff >=0 and dea >=0;
short:diff<=0 and dea<=0;
KD:=Long;
PD:=short;
KK:=short;
PK:=long;
平空:SELLSHORT(PK,1,THISCLOSE);
开多:BUY(KD AND HOLDING=0,1,THISCLOSE);
平多:SELL(PD,1,THISCLOSE);
开空:BUYSHORT(KK AND HOLDING=0,1,THISCLOSE);