[PEL] 复制代码 tcd:(time>=010000 and time<185700);
variable:num:=0; // 全局变量
cs:=3; //限定一天最多亏损3次
ma1:=ma(c,20);
kd:close>ma1; //开多条件
pd:=close<ma1; //平多条件
kk:=close<ma1; //开空条件
pk:=close>ma1; //平空条件
ss:=1;//手数
//多
if pd and holding>0 then
begin
sell(1,ss,limitr,close);
if numprofit(1)<0 then num:=num+1; //平多仓
end
if kd and tcd and holding=0 and num<cs then //开多仓
begin
buy(1,ss,limitr,close);
end
//空
if pk and holding<0 then
begin
sellshort(1,ss,limitr,close);
if numprofit(1)<0 then num:=num+1; //平空仓
end
if kk and tcd and holding=0 and num<cs then //开空仓
begin
buyshort(1,ss,limitr,close);
end
if time=closetime(0) then num:=0;
亏损次数:num;
//指定时间平仓
if time=185700 then begin
收盘a:sell(1,ss,limitr,close)coloryellow;//平多
收盘:sellshort(1,ss,limitr,close)colorgreen;//平空
end
hd:holding; |