[PEL] 复制代码 ma20:=ma(close,20);
kd:=close>ma20; //开多条件
pd:=close<ma20; //平多条件
kk:=close<ma20; //开空条件
pk:=close>ma20; //平空条件
variable:num:=0;
cs:=9;//加仓次数上限
if pk and holding<0 then
begin
平空:sellshort(pk,0,thisclose);
if NUMPROFIT(1)<0 then num:=num+1;
if NUMPROFIT(1)>0 then num:=0;
end
if pd and holding>0 then
begin
平多:sell(pd,0,thisclose);
if NUMPROFIT(1)<0 then num:=num+1;
if NUMPROFIT(1)>0 then num:=0;
end
if kd and holding=0 then
begin
开多:buy(kd and holding=0,1*POW(2,num),thisclose);
end
if kk and holding=0 then
begin
开空:buyshort(kk and holding=0,1*POW(2,num),thisclose);
end
if num=cs then num:=0;
持仓:holding; |