哦,我明白你的意思了,我忽略了你用了这个条件,这种情况下无法用enterbars,因为他只表示最近信号的了,你还可以用我的办法,只是要继续用超全局变量了:
globalvariant:hold1=0,hold2=0,enterbars1=-1,enterbars2=-1,enterprice1=0,enterprice2=0;
//策略1.
enterbars1:=enterbars1+1;
if holding>0 and hold1>0 and enterbars1>=1 and c>=enterprice1 then
begin
hold1:=hold1-1;
enterbars1:=0;
enterprice1:=c;
sell(1,100%,thisclose);//买入后赚钱就卖。
end;
if holding>0 and hold1>0 and enterbars=3 then
begin
hold1:=hold1-1;
sell(1,100%,thisclose);//3个bar不管输赢都卖掉。
end;
if ref(c,1)>ref(c,2) then
begin
hold1:=hold1+1;
buy(1,1,limitr,o);//当昨日收阳买入。
end;
策略2你用相同的原理改写,应该不用我写给你了