止盈后朝原本有利的方向 运动了x%后开仓,盈利x点后平仓。
止盈之后还有持仓,然后判断这个持仓是否仍然盈利?
止盈之后就没有仓位了。因为有时候止盈完之后会损失有利的行情,就想止损后朝有利方向继续运动了就再开回仓位。
variable:n=0;
variable:m=0;//用全局变量来控制平仓之后的重新开仓,避免对原有的正常开仓进行处理
if type(1)=2 and (h-exitprice)/exitprice>0.0x and n=0 and holding=0 then begin
buy(holding=0,1,market);
n:=1;
end
if (h-enterprice)>x and n=1 and holding>0 then begin
sell(1,0,market);
n:=0;
end
if type(1)=4 and (exitprice-l)/exitprice>0.0x and m=0 and holding=0 then begin
buyshort(holding=0,1,market);
m:=1;
end
if (enterprice-l)>x and m=1 and holding<0 then begin
sellshort(1,0,market);
m:=0;
end