[PEL] 复制代码 variable:p1:=0,p2:=0,p3:=0,p4:=0;//四个全局变量记录四个开仓价格(开仓+加仓)
ma10:ma(c,10);
kd:cross(c,ma10);
pd:cross(ma10,c);
if c-enterprice>=5*mindiff and holding>0 then
begin
if (p2=0 or p3=0 or p4=0 ) then 加仓:buy(1,1,marketr);
if p3<>0 and p4=0 then p4:=enterprice;
if p2<>0 and p3=0 then p3:=enterprice;
if p1<>0 and p2=0 then p2:=enterprice;
end
if holding=0 and kd then
begin
初始开仓:buy(1,1,marketr);
p1:=enterprice;
p2:=0;
p3:=0;
p4:=0;
end
if pd then
begin
全平:sell(1,holding,market);
end
if p1>0 and c<p1 and holding>0 then
begin
减仓1:sell(1,1,market);
p1:=-1;
end
if p2>0 and c<p2 and holding>0 then
begin
减仓2:sell(1,1,market);
p2:=-1;
end
if p3>0 and c<p3 and holding>0 then
begin
减仓3:sell(1,1,market);
p3:=-1;
end
if p4>0 and c<p4 and holding>0 then
begin
减仓4:sell(1,1,market);
p4:=-1;
end
|