这个要写一个具体的框架的,用户带进自己的条件即可
variable:n=0;
if 平多条件 and holding>0 then begin
sell(1,0,marketr);
if numprofit(1)>0 then n:=0;
if numprofit(1)<0 then n:=n+1;
end
if 平空条件 and holding<0 then begin
sellshort(1,0,marketr);
if numprofit(1)>0 then n:=0;
if numprofit(1)<0 then n:=n+1;
end
n为当前连亏次数
variable:n=0;
if 平多条件 and holding>0 then begin
sell(1,0,marketr);
nn:=(exitpricie-enterprice)/enterprice;
if nn>=0.03 then n:=0;
if nn<0.03 then n:=n+1;
end
if 平空条件 and holding<0 then begin
nn:=(enterprice-exitprice)/exitprice;
sellshort(1,0,marketr);
if nn>=0.03 then n:=0;
if nn<0.03 then n:=n+1;
end
你这样写不能写在平仓语句前, 获取的值不是当次平仓的值了