日内交易平仓后亏损超20%,不再开仓该如何实现
在开仓条件中增加一个亏损判断:abs(avgenterprice-c)/avgenterprice<=0.2
我是用后台程序化的,该怎么实现呢?
GLOBALVARIABLE:n=0,m=0,x=0;
if date<>ref(date,1) then x:=0;
if tbuycond and x=0 then begin
tbuy(1,1,mkt);
n:=tASSET;
end
if tsellcond then begin
tsell(1,1,mkt);
m:=tasset;
end
if (m-n)/n>=0.2 then x:=1;
(m-n)/n>=0.2
m是平仓前的资金,n是平仓后的资金,判断平仓后是否亏损20%。