//股指與300ETF之間的價差套利代碼演示
//做空股指
VERTLINE(time=CLOSETIME(0),hhv(h,240/5),llv(l,240/5),coloryellow,1,vtDASH);
股指:"IF00$CLOSE",linethick0;
滬深300:"000300$CLOSE",linethick0;
差值:股指-滬深300,linethick0;
?
short:=差值>=20;
shortend:=差值<=10;
t1:=time>093500 and time<145500;
?
if holding=0 and t1 then begin
buyshort(short,1,thisclose);
end
?
if holding<0 and t1 then sellshort(shortend,1,thisclose);
?
?
?
?
VERTLINE(time=CLOSETIME(0),hhv(h,240/5),llv(l,240/5),coloryellow,1,vtDASH);
股指:"IF00$CLOSE",linethick0;
滬深300:"000300$CLOSE",linethick0;
差值:股指-滬深300,linethick0;
?
long:=差值>=20;
longend:=差值<=10;
t1:=time>093500 and time<145500;
?
if holding=0 and t1 then begin
buy(long,1,thisclose);//www.kzuj.com.cn
end
?
if holding>0 and t1 then sell(longend,1,thisclose);
?
?
//特別提示,一手股指的合約金額比較大,對應的ETF份數也比較大。這里需要自行調節買賣的ETF份數