con1:=cross(ma5,ma20);
con2:=cross(ma20,ma5);
if cond2 and holding>0 then
begin
sell(1,1,thisclose);
if c<enterprice then lossnum:=lossnum+1;//亏损手数
if c>enterprice then lossnum:=1;//盈利置1
end
if cond1 and holding=0 and lossnum<cs then buy(1,lossnum,thisclose);
variable:lossnum=1;// 全局变量,平仓时判断一下是盈利/亏损,若亏损lossnum就加1
ma5:=ma(5,close);
ma20:=ma(20,close);
cond1:=cross(ma5,ma20);
cond2:=cross(ma20,ma5);
if cond2 and holding>0 then
begin
sell(1,1,thisclose);
if c<enterprice then lossnum:=lossnum+1;//亏损手数
if c>enterprice then lossnum:=1;//盈利置1
end
if cond1 and holding =0 then buy(1,lossnum,thisclose);