[PEL] 复制代码
VARIABLE:lx:=0;
ma5:ma(c,5);
ma10:ma(c,10);
kd:=cross(ma5,ma10);
pd:=cross(ma10,ma5);
sell(pd,holding,marketr);
ast1:valuewhen(holding=0,asset);//获取最近一次空仓时候的资产数值,这个语句应当放在平仓语句后,开仓语句之前。
pcyk:valuewhen(ast1<>ref(ast1,1),ast1-ref(ast1,1));//最近一次平仓盈亏
if pcyk<0 and ast1<>ref(ast1,1) then
begin
if lx>0 then lx:=0;
lx:=lx-1;
end
if pcyk>0 and ast1<>ref(ast1,1) then
begin
if lx<0 then lx:=0;
lx:=lx+1;
end
连续涨跌次数:lx;//负数表示连续跌了几次,正数表示连续涨了几次
buy(kd and holding=0,1,marketr);
r1:count(ast1>ref(ast1,1),0);//盈利总次数
r2:count(ast1<ref(ast1,1),0);//亏损总次数 |