input:period(60,5,120,5);
input:length(20,5,40,5);
input:trailingstop(3,1,6,1);
variable:stopline=0;
topband:=ref(hhv(high,period),1)+mindiff;
botband:=ref(llv(low,20),1)-mindiff;
atr:=ref(ma(tr,length),1);
trailingstopnum:=trimprice(trailingstop*atr);
if holding=0 then begin
if barpos>period and high>=topband then
buy(1,100%,limitr,close);
end
if holding>0 then begin
if high-trailingstopnum>stopline then
stopline:=high-trailingstopnum;
if enterbars>=2 and low<=stopline then begin
sell(1,holding,limitr,close);
stopline:=0;
end
end
partline(holding>0 and enterbars>=2,stopline,coloryellow,1);
盈亏:asset,noaxis,colormagenta;
收益:(asset-500000)/500000,linethick0;
次数:totaltrade,linethick0;
胜率:percentwin,linethick0;
连亏:maxseqloss,linethick0;
连赢:maxseqwin,linethick0;