variable:n=0;
if 开仓条件1 and holding=0 then begin
下单语句;
n:=1;
end
if 开仓条件2 and holding=0 then begin
下单语句;
n:=2;
end
if 开仓条件3 and holding=0 then begin
下单语句;
n:=3;
end
if 平仓语句1 and n=1 then 平仓语句;
if 平仓语句2 and n=2 then 平仓语句;
if 平仓语句3 and n=3 then 平仓语句;
variable:n=0; if 开仓条件1 and holding=0 then begin 下单语句; n:=1; end 假定成立,开仓了,持仓量就大于0了 if 开仓条件2 and holding=0 then begin 下单语句; n:=2; end 但因为持仓量大于0,不满足HOLDING=0,所以不会有开仓动作,即不满足IF的判断,那N如何得到赋值2? if 开仓条件3 and holding=0 then begin 下单语句; n:=3; end
if 平仓语句1 and n=1 then 平仓语句;
if 平仓语句2 and n=2 then 平仓语句;
if 平仓语句3 and n=3 then 平仓语句; |
variable:n=0;
variable:m1=0,m2=0,m3=0;
if 开仓条件1 and holding=0 then begin
下单语句;
n:=1;
end
if 开仓条件2 and holding=0 then begin
下单语句;
n:=2;
end
if 开仓条件3 and holding=0 then begin
下单语句;
n:=3;
end
if 开仓条件1 then m1:=1;
if 开仓条件2 then m2:=1;
if 开仓条件3 then m3:=1;
if 平仓语句1 and n=1 then begin
平仓语句;
m1:=0;
m2:=0;
m3:=0;
end
if 平仓语句2 and n=2 then begin
平仓语句;
m1:=0;
m2:=0;
m3:=0;
end
if 平仓语句3 and n=3 then begin
平仓语句;
m1:=0;
m2:=0;
m3:=0;
end
n=1 切m2=1,m3=1时,表示条件1开仓时,条件2和条件3成立过,
m1=1表示条件1成立过,不管有没有开仓,
m1=2表示条件2成立过,不管有没有开仓,
m1=3表示条件3成立过,不管有没有开仓,