初学金字塔,很多问题没有解决,请教如下:
想实现一个想法,第一根K线是阳线时第二根K线开盘开多,第一根K线是阴线时,第二根K线开盘开空,临近收盘平仓。但是应用在股指期货1分钟K线上发现开盘开仓可以实现,但是收盘时平仓似乎不能实现。经常发现同时持有多空仓的情况。怎么也找不到原因,究竟哪里出错呢?麻烦版主或其他高手给看看,谢啦!
runmode:0;
if holding=0 then do begin
if time=0916 and open<close then buy(1,1,limit,open-mindiff);
if time=0916 and open>close then buyshort(1,1,limit,open+mindiff);
end;
if holding>0 and time=1500 then sell(1,1,limit,open+mindiff);
if holding<0 and time=1500 then sellshort(1,1,limit,open+mindiff);
问题正在查找中 稍后回复
runmode:0;
//股指1分钟周期
r1:=ref(open,1)<ref(close,1);
r2:=ref(open,1)>ref(close,1);
h1:holding,linethick0;
if holding=0 and time=091700 then begin
buy(r1,1,thisclose);
buyshort(r2,1,thisclose);
end;
if holding>0 and time>=151400 then sell(1,0,thisclose);
if holding<0 and time>=151400 then sellshort(1,0,thisclose);
runmode:0;
if time=091600 and c>o then begin
buy(1,1,limit,close+mindiff);
end
if time=091600 and c<o then begin
buyshort(1,1,limit,close-mindiff);
end
if time=150000 then begin
sell(holding>0,0,limit,close-mindiff) ;
sellshort(holding<0,0,limit,close+mindiff);
end
价格问题,还有你这个必须使用K线走完模式
金哲给的代码已经实现了这个想法了,感谢这么快回复!