n:=barslast(date<>ref(date,1));
zg:valuewhen(date<>ref(date,1),ref(hhv(h,n+1),1));//昨高
zd:valuewhen(date<>ref(date,1),ref(llv(l,n+1),1));//昨低
zs:valuewhen(date<>ref(date,1),ref(c,1));//昨收
jg:hhv(h,n+1);//今高
jd:llv(l,n+1);//今低
ssetup:=zg+0.35*(zs-zd);//中轨上顶部区间
senter:=(1.07/2)*(zg+zd)-0.07*zd;
benter:=(1.07/2)*(zg+zd)-0.07*zg;
zgsqj:=senter+(zg-ssetup)/3;//中轨上区间
zgxqj:=benter-(ssetup-zd)/3;//中轨下区间
bsetup:=zd-0.35*(zg-zs);
bbreak:=(ssetup+0.25*(ssetup-bsetup));//上轨
sbreak:=bsetup-0.25*(ssetup-bsetup);//下轨
if cross( c,bbreak ) then buy(holding=0,1,thisclose);
if jg>zgsqj and jg<bbreak and cross(zgsqj,c) then begin
sell(holding>0,0,thisclose);
buyshort(holding=0,1,thisclose);
end
if cross(c,sbreak) then buyshort(holding=0,1,thisclose);
if jd<zgxqj and c>sbreak and cross(c,zgxqj) then begin
sellshort(holding<0,0,thisclose);
buy(holding=0,1,thisclose);
end
按照6楼的意思大致写了下
[此贴子已经被作者于2011-11-11 15:18:57编辑过]