比如1分钟k线
r1:=ma(c,5);
r2:=ma(c,10);
if barpos=1 then buyshort(holding=0,1,thisclose);
if holding=0 and enterbars>=60 and cross(r1,r2) then buy(holding=0,1,thisclose);
if holding=0 and enterbars>=60 and cross(r2,r1) then buyshort(holding=0,1,thisclose);
if holding>0 and cross(r2,r1) then sell(holding>0,0,thisclose);
if holding<0 and cross(r1,r2) then sellshort(holding<0,0, thisclose);
注意:1.这个程序只能做测试用,如果实盘交易限制k线数量,会引起信号变化;
2.对于日内交易要考虑第一次开仓的问题;