以下案例仅供参考。
variable:price=0; //定义全局变量price
diff:=ema(close,12)-ema(close,26);
con1:cross(diff,0);
con2:cross(0,diff);
if con1 then begin //diff上穿0轴时,平空单,开5手多单
sellshort(holding<0,holding,market);
buy(holding=0,5,market);
price:=enterprice;
end
if con2 then begin //diff下穿0轴时,平多单,开5手空单
sell(holding>0,holding,market);
buyshort(holding=0,5,market);
price:=enterprice;
end
if holding>0 and c-price>=10*mindiff then begin //多单盈利每10点,平1手
sell(1,1,market);
price:=c;
end
if holding<0 and price-c>=10*mindiff then begin //空单盈利每10点,平1手
sellshort(1,1,market);
price:=c;
end
[此贴子已经被作者于2019/7/8 9:28:57编辑过]