ma1:=ma(c,37);
ma2:=ma(c,241);
cond1:cross(ma1,ma2);
cond2:cross(ma2,ma1);
buy(cond1,1,MARKET);
BUYSHORT(cond2,1,MARKET);
bo:(hhv(c,ENTERBARS)-c)/enterprice;
if bo>0.8 and holding>0 then sell(1,holding,MARKET);
楼上思路正确,但是要加上以下内容:
1.cond1:cross(ma1,ma2) and holding=0;
cond2:cross(ma2,ma1) and holding=0
2.
一个空头止损
po:=(enterprice-(llv(l,enterbars+1)))/enterprice;
if bo>0.8 and holding>0 then sell(1,holding,MARKET);