后台在非走完K线模式下,tholding=0 这样的条件是非常危险的。
具体请参考 http://www.weistock.com/bbs/dispbbs.asp?boardid=16&Id=332 问题15.
解决方案是 tholding=0 时还要加以判断是否有未成交的委托单,请参考 http://www.weistock.com:8080/vip/forum.php?mod=viewthread&tid=289&extra=page%3D1 这里的部分范例代码
道理上是一样的,就是对未成交单的一个判断
if tholding2=0 and TREMAINQTY(1,'','')=0 and TREMAINQTY(3,'','')=0 then extgbdataset('orderdone',0);
if (TREMAINQTY(1,'','')>0 or TREMAINQTY(3,'','')>0) and tholding2=0 then extgbdataset('orderdone',1);
if abs(tholding2)>0 and not(extgbdata('orderdone')=3) then extgbdataset('orderdone',2);
if sellcondZB and tbuyholding(1)>0 then begin
tcancel(1,2);tcancel(1,4);
平多ZB1:tsell(1,tbuyholding(1),mkt);
if Islastbar then DEBUGFILE2('D:\NTGAN.TXT',' sellcondZB:'&numtostr(sellcondZB,0)&' tholding2='&numtostr(tholding2,0)&' 开多:'&numtostr(TREMAINQTY(1,'',''),0)&' 开空:'&numtostr(TREMAINQTY(3,'',''),0)&' orderdorderdone'),1);
sleep(m);
if tholding2=0 and TREMAINQTY(1,'','')=0 and TREMAINQTY(3,'','')=0 then extgbdataset('orderdone',0);
end
if buyshortcondZB0 then begin
tcancel(1,3);tcancel(1,1);
if TREMAINQTY(1,'','')=0 and TREMAINQTY(3,'','')=0 and tholding2=0 then begin
开空ZB0:tbuyshort(1,1,mkt);
if Islastbar then DEBUGFILE2('D:\NTGAN.TXT',' buyshortcondZB0:'&numtostr(buyshortcondZB0,0)&' tholding2='&numtostr(tholding2,0)&' 开多:'&numtostr(TREMAINQTY(1,'',''),0)&' 开空:'&numtostr(TREMAINQTY(3,'',''),0)&' orderdorderdone'),1);
sleep(n);
if (TREMAINQTY(1,'','')>0 or TREMAINQTY(3,'','')>0) and tholding2=0 then extgbdataset('orderdone',1);
if abs(tholding2)>0 and extgbdata('orderdone')=1 then extgbdataset('orderdone',2);
end
end
if sellshortcondZB and tsellholding(1)>0 then begin
tcancel(1,2);tcancel(1,4);
平空ZB1:tsellshort(1,tsellholding(1),mkt);
if Islastbar then DEBUGFILE2('D:\NTGAN.TXT',' sellshortcondZB:'&numtostr(sellshortcondZB,0)&' tholding2='&numtostr(tholding2,0)&' 开多:'&numtostr(TREMAINQTY(1,'',''),0)&' 开空:'&numtostr(TREMAINQTY(3,'',''),0)&' orderdorderdone'),1);
sleep(m);
if tholding2=0 and TREMAINQTY(1,'','')=0 and TREMAINQTY(3,'','')=0 then extgbdataset('orderdone',0);
end
if buycondZB0 then begin
tcancel(1,3);tcancel(1,1);
if TREMAINQTY(1,'','')=0 and TREMAINQTY(3,'','')=0 and tholding2=0 then begin
开多ZB0:tbuy(1,1,mkt);
if Islastbar then DEBUGFILE2('D:\NTGAN.TXT',' buycondZB0:'&numtostr(buycondZB0,0)&' tholding2='&numtostr(tholding2,0)&' 开多:'&numtostr(TREMAINQTY(1,'',''),0)&' 开空:'&numtostr(TREMAINQTY(3,'',''),0)&' orderdorderdone'),1);
sleep(n);
if (TREMAINQTY(1,'','')>0 or TREMAINQTY(3,'','')>0) and tholding2=0 then extgbdataset('orderdone',1);
if abs(tholding2)>0 and extgbdata('orderdone')=1 then extgbdataset('orderdone',2);
end
end
其实都有做控制的,但还是不行,我是每秒固定轮询的
N您好,勾下交易日志看下