if c>enterprice*1.05 then sellshort(holding<0,0,market);
if c<enterprice*0.95 then sell(holding>0,0,market);
r1:=barslast(holding<>0);
r2:=ref(asset,r1);
if asset/r2<0.95 then
begin
sell(holding>0,0,thisclose);
sellshort(holding<0,0,thisclose);
end
自己调试一下
用下列可能更好(固定轮询,高频扫描)
r1:=barslast(holding<>0);
r2:=ref(asset,r1);
if asset/r2<0.95 then
begin
sell(holding>0,0,limitr,c);
sellshort(holding<0,0,limitr,c);
end