金字塔股指与300ETF之间的价差套利代码
源码如下:[code]
//股指与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);
//做多300ETF www.cxh99.com
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.cxh99.com
end
if holding>0 and t1 then sell(longend,1,thisclose);
//特别提示,一手股指的合约金额比较大,对应的ETF份数也比较大。这里需要自行调节买卖的ETF份数
[/code]
页:
[1]