本帖最后由 技术009 于 2023-11-17 13:28 编辑
1.你这里 “IM当月和下月” 你要在图表上 你就要在品种月份更换时候 手工去调整图表上交易的品种 以及代码里的品种。
2.图表这里离场 只能是单品种盈亏点数来执行。无法协调2个品种共同的盈亏点数来。如果跨指标调用,则会形成指标相互调用的循环引用的情况。
3.无法保证能实现套利。因为2个品种实际在图表模型上是各自跑各自的 离场的时机无法保持一致。
到时候可能会出现单腿情况以及其他仓位操作不一致的情况
[PEL] 复制代码
code1:='im12';
code2:='im01';
dc1:=callstock(code1,vtclose,6,-1);
dc2:=callstock(code2,vtclose,6,-1);
m1:=c;
m2:=callstock(code2,vtclose,-1,0);
zdf1:100*(m1-dc1)/dc1,nodraw;
zdf2:100*(m2-dc2)/dc2,nodraw;
szzs:=callstock('sh000001',vtclose,-1,0);//上证最新价
last_szzs:=callstock('sh000001',vtclose,6,-1);//上证昨日收盘价
kcon:abs(zdf1-zdf2)>=0.2;//涨跌幅百分百差值的绝对值大于等于0.2
pd:=(avgenterprice-c)>=25*mindiff;//单品种多止盈
pk:=(c-avgenterprice)>=25*mindiff;//单品种空止盈
//im当月
if stricmp(stklabel,code1)=0 then
begin
if kcon and holding=0 and szzs<last_szzs then buy(1,1,market);
if kcon and holding=0 and szzs>last_szzs then buyshort(1,1,market);
end
//im次月
if stricmp(stklabel,code2)=0 then
begin
if kcon and holding=0 and szzs<last_szzs then buyshort(1,1,market);
if kcon and holding=0 and szzs>last_szzs then buy(1,1,market);
end
//止损离场
if holding>0 and pd then sell(1,holding,market);
if holding<0 and pk then sellshort(1,holding,market);
|