VARIABLE:n:=0;
if 开多条件 and n=0 then
begin
buy(holding=0,1,market);
n:=1;
end
sell(平多条件 and holding>0,1,market);
if 开空条件 and n=0 then
begin
buyshort(holding=0,1,market);
n:=2;
end
sellshort(平空条件 and holding<0,1,market);
if EXITPRICE-ENTERPRICE>0 and n=2 then buy(holding=0,1,market);//n=2判断上次是开空
if enterprice-EXITPRICE>0 and n=1 THEN buyshort(holding=0,1,market);//n=1判断上次是开多
if time=closetime(0) then n:=0;
VARIABLE:n:=0;
if 开多条件 and n=0 then
begin
buy(holding=0,1,market);
n:=1;
end
sell(平多条件 and holding>0,1,market);
if 开空条件 and n=0 then
begin
buyshort(holding=0,1,market);
n:=2;
end
sellshort(平空条件 and holding<0,1,market);
if EXITPRICE-ENTERPRICE>0 and n=2 then buy(holding=0,1,market);//n=2判断上次是开空
if enterprice-EXITPRICE>0 and n=1 THEN buyshort(holding=0,1,market);//n=1判断上次是开多
if time=closetime(0) then n:=0;
这里的holidng判断写在和开多开空条件一起判断,不要放在后面
VARIABLE:n:=0;
if 开多条件 and n=0 and holding=0 then
begin
buy(holding=0,1,market);
end
sell(平多条件 and holding>0,1,market);
if 开空条件 and n=0 and holding=0 then
begin
buyshort(holding=0,1,market);
end
sellshort(平空条件 and holding<0,1,market);
nn1:=barslast(开多条件);
nn2:=barslast(开空条件);
if nn1>nn2 and exitbars>0 and exitprice>enterprice then n:=1;
if nn1<nn2 and exitbars>0 and exitprice<enterprice then n:=1;
if time=closetime(0) then n:=0;