VARIABLE:x=0,y=0;
MA1:REF(MA(((H+L+C)/3,N)),1);//三价平均线
浮动区间:=REF(MA(TR,N),1);//真实振幅的移动平均线
上轨:MA1+浮动区间;
下轨:MA1-浮动区间;
hh:hhv(h,todaybar);
ll:llv(l,todaybar);
if todaybar=120 then begin
x:=0;
y:=0;
end
if h>ref(h,1) and todaybar>=120 and x=0 then begin
buy(holding=0,1,market);
x:=1;
end
if l<ref(l,1) and todaybar>=120 and y=0 then begin
buyshort(holding=0,1,market);
y:=1;
end
dzy:cross(下轨,l);//开多止盈
kzy:cross(h,上轨);
dzs:cross(ref(l,enterbars+1),l);
kzs:cross(h,ref(h,enterbars+1));
sell(holding>0 and (dzy or dzs),holding,market);
sellshort(holding<0 and (kzy or kzs),holding,market);