
runmode:0;
variable:stopline=0;
entrylongcond:=ref(high,1)>ref(high,2) and ref(high,2)>ref(high,3) and ref(low,2)entryshortcond:=ref(low,1)[ref(high,3) and ref(low,2)]
atr:=3*ma(tr,15);
hh:=ref(high,1);
ll:=ref(low,1);
if holding=0 then begin
if entrylongcond then begin
buy(1,1,limitr,open);
stopline=:enterprice-atr;
end
if entryshortcond then begin
buyshort(1,1,limitr,open);
stopline:=enterprice+atr;
end
end
if holding>0 and enterbars>=1 then begin
if hh-atr>stopline then
stopline:=hh-atr;
if low<=stopline then
sell(1,holding,limitr,min(open,stopline));
end
if holding<0 and enterbars>=1 then begin
if ll+atr stopline:=ll+atr;
if high>=stopline then
sellshort(1,holding,limitr,max(open,stopline));
end
盈亏:asset-500000,noaxis,coloryellow,linethick2;