[PEL] 复制代码
variable:num:=0; // 全局变量,来控制同条件加仓次数
cs:=3; //限定最多加仓3次
ma5:=ma(close, 5);
ma20:=ma(close, 20);
cond1:=cross(ma5,ma20);
cond2:=cross(ma20,ma5);
if cond2 and holding>0 then
begin
sell(1,1,market);//平仓
num:=0;
end
if cond1 and cond1 and holding=0 then buy(1,1,market); //首次开仓
//7.0版本该函数有效
time_min1:callstock('',vttime,1,0);
tcon:time_min1<=185900;//最后一分钟不执行加仓,即59分到结束的1分钟
if cond1 and holding>0 and num<cs and tcon then //加仓3次
begin
buy(1,1,market);
num:=num+1;
end
if c/avgenterprice>=1.01 and holding>0 then
begin
多止盈:sell(1,holding,market);
num:=0;
end
if c/avgenterprice<=0.99 and holding>0 then
begin
多止损:sell(1,holding,market);
num:=0;
end |