ma5:ma(c,5);//五日均线
ma10:ma(c,10);//十日均线
buycond:cross(ma5,ma10);//开多条件
sellcond:cross(ma10,ma5);//平多条件
if buycond then buy(holding=0,1,market);//开多下单
if sellcond then sell(holding>0,holding,market);
老师,能回复我吗?
buy 开多
sell 平多
buyshort 开空
sellshort 平空
条件就是之前的代码,没变。你按照需要使用上述函数即可。你先尝试下。
input:a(5,1,100,1),b(10,1,100,1);
ma5:ma(c,a);//五日均线,a默认是五,可以通过参数调整修改
ma10:ma(c,b);//十日均线,b默认是十
buycond:cross(ma5,ma10);//开多条件
sellcond:cross(ma10,ma5);//平多条件
if buycond then
begin
sellshort(holding<0,holding,market);
buy(holding=0,1,market);//开多下单
end
if sellcond then
begin
sell(holding>0,holding,market);
buyshort(holding=0,1,market);
end
平仓反手