variable:n=0;
variable:m=0;
if 开仓条件1 and n=0 then begin
下单语句;
n:=1;
end
if 开仓条件2 and n=0 then begin
下单语句;
n:=1;
end
if 开仓条件3 and n=0 then begin
下单语句;
n:=1;
end//有几个开仓语句,这样的开仓就写几遍
if 平仓条件1 and m=0 then begin
平仓语句;
m:=1;
end
if 平仓条件2 and m=0 then begin
平仓语句;
m:=1;
end
if 平仓条件3 and m=0 then begin
平仓语句;
m:=1;
end//同开仓
n:=0;
m:=0;
这样写,不行啊。
分析如下:
第一次扫描的时候,开仓条件1成立,n=0,所以开仓了,后续的开仓条件都不开仓是对的。
第二次扫描的时候,开仓条件1是不成立,但是开仓条件2成立了,n=0,所以,再次开仓了。(因为第一次扫描的最后已经将n、m清零)
因为开仓条件,不是同一次扫描同时成立的,而是不同的扫描的时候,成立了。
你试过了没有?图表上的信号有没有多?