runmode:0;
input:avglength(40),atrlength(40);
ma1:=ref(ma((high+low+close)/3,avglength),1);
upperband:=ma1+ref(ma(tr,atrlength),1);
lowerband:=ma1-ref(ma(tr,atrlength),1);
entrylongcond:=ma1>ref(ma1,1) and high>=upperband;
exitlongcond:=low<=ma1;
entryshortcond:=ma1<ref(ma1,1) and low<=lowerband;
exitshortcond:=high>=ma1;
if holding=0 then begin
if entrylongcond then
buy(1,1,limitr,max(open,upperband));
end
if holding=0 then begin
if entryshortcond then
buyshort(1,1,limitr,min(open,lowerband));
end
if holding>0 then begin
if exitlongcond then
sell(1,holding,limitr,min(open,ma1));
end
if holding<0 then begin
if exitshortcond then
sellshort(1,holding,limitr,max(open,ma1));
end
盈亏:asset-50000,noaxis,colorred,linethick2;