怎么把oo定義成為 平空? 或者平多 處的價(jià)位呢???
下文定義oo是當(dāng)日開(kāi)盤(pán)價(jià),我想把它改成 平倉(cāng)處的價(jià)位 ,怎么寫(xiě)呢?求指導(dǎo)
input:grid(3,1,60,1);
variable:level=0;
dist:=barslast(date<>ref(date,1));
oo:=ref(open,dist);
?
if holding=0 then begin
?dnprice:=oo-grid*mindiff;
?
?if low<=dnprice then begin
??buy(1,1,limitr,dnprice);
??level:=-1;
?end
end?
if holding=0 then begin
?upprice:=oo+grid*mindiff;
?
?if high>=upprice then begin
??buyshort(1,1,limitr,upprice);
??level:=1;
?end?
end
if holding>0 then begin
?upprice:=oo+(level+1)*grid*mindiff;
?dnprice:=oo+(level-1)*grid*mindiff;
?
?if high>=upprice then begin
??sell(1,1,limitr,upprice);
??level:=level+1;
?end
?
?if low<=dnprice then begin
??buy(1,1,limitr,dnprice);
??level:=level-1;
?end
?
?if time=closetime(0) then
??sell(1,holding,limitr,close);
end?
if holding<0 then begin?
?upprice:=oo+(level+1)*grid*mindiff;
?dnprice:=oo+(level-1)*grid*mindiff;
?
?if low<=dnprice then begin
??sellshort(1,1,limitr,dnprice);
??level:=level-1;
?end
?
?if high>=upprice then begin
??buyshort(1,1,limitr,upprice);
??level:=level+1;
?end
?
?if time=closetime(0) then
??sellshort(1,holding,limitr,close);
end
?
limitr 后邊的參數(shù)就是限價(jià)的價(jià)格,改成oo就可以了。
input:grid(3,1,60,1);
variable:level=0;
dist:=barslast(date<>ref(date,1));
oo:=ref(open,dist);
?
if holding=0 then begin
?dnprice:=oo-grid*mindiff;
?
?if low<=dnprice then begin
??buy(1,1,limitr,dnprice);
??level:=-1;
?end
end?
if holding=0 then begin
?upprice:=oo+grid*mindiff;
?
?if high>=upprice then begin
??buyshort(1,1,limitr,upprice);
??level:=1;
?end?
end
if holding>0 then begin
?upprice:=oo+(level+1)*grid*mindiff;
?dnprice:=oo+(level-1)*grid*mindiff;
?
?if high>=upprice then begin
??sell(1,1,limitr,oo);
??level:=level+1;
?end
?
?if low<=dnprice then begin
??buy(1,1,limitr,dnprice);
??level:=level-1;
?end
?
?if time=closetime(0) then
??sell(1,holding,limitr,oo);
end?
if holding<0 then begin?
?upprice:=oo+(level+1)*grid*mindiff;
?dnprice:=oo+(level-1)*grid*mindiff;
?
?if low<=dnprice then begin
??sellshort(1,1,limitr,oo);
??level:=level-1;
?end
?
?if high>=upprice then begin
??buyshort(1,1,limitr,upprice);
??level:=level+1;
?end
?
?if time=closetime(0) then
??sellshort(1,holding,limitr,oo);
end