//日内连续亏损5次则不开仓
VARIABLE:ks=0;//连续亏损次数
num:=5;
buycond:=ref(count(c>o,2)=2,1);
sellcond:=ref(count(c<o,2)=2,1);
if holding>0 and sellcond then
begin
sell(1,1,market);
if c<ENTERPRICE then ks:=ks+1;
else
if c>ENTERPRICE then ks:=0;//赢利一次,重新计算亏损次数
end
if holding<0 and buycond then
begin
sellshort(1,1,market);
if c>ENTERPRICE then ks:=ks+1;
else
if c<ENTERPRICE then ks:=0;//赢利一次,重新计算亏损次数
end
if buycond and holding=0 and ks<=num then
begin
buy(1,1,market);
end
if holding=0 and sellcond and ks<=num then buyshort(1,1,market);
if time=closetime(0) then ks:=0;//收盘的同时,赋值为0
if holding=0 and sellcond and ks<=num then
begin buyshort(1,1,market);
end
if time=closetime(0) then ks:=0;//收盘的同时,赋值为0
VARIABLE:ks=0;//连续亏损次数
num:=5;
buycond:=ref(count(c>o,2)=2,1);
sellcond:=ref(count(c<o,2)=2,1);
if holding>0 and sellcond then
begin
sell(1,1,market);
if c<ENTERPRICE then ks:=ks+1;
else
if c>ENTERPRICE then ks:=0;//赢利一次,重新计算亏损次数
end
if holding<0 and buycond then
begin
sellshort(1,1,market);
if c>ENTERPRICE then ks:=ks+1;
else
if c<ENTERPRICE then ks:=0;//赢利一次,重新计算亏损次数
end
if buycond and holding=0 and ks<=num then
begin
buy(1,1,market);
end
if holding=0 and sellcond and ks<=num then
begin
buyshort(1,1,market);
end
if time=closetime(0) then ks:=0;//收盘的同时,赋值为0