开平仓函数如下:运行模式用固定1秒间隔模式,盘中有出现重复开仓的情况,该函数不是检测了仓位=0才开吗?为什么还会重复?请教下是哪里出错了?
if pk then tSELLSHORT(1,0,mkt); //平空信号
if kd and tholding=0 then begin
tSELLSHORT(1,0,mkt);
tBUY(1,1,mkt); //开多信号
end
if pd then tSELL(1,0,mkt); //平多信号
if kk and tholding=0 then begin
tSELL(1,0,mkt);
tBUYSHORT(1,1,mkt); //开空信号
end
请具体的讲一下“重复下单”的情况,是重复下同方向单,还是下反方向单?有记录下单日志吗?
那么当时的持仓情况是什么?同时有多头和空头持仓吗?
if kd and tholding=0 then begin
这里有病句的,你1秒间隔扫描,从上一笔下单到最后成交是可能大于1秒的,tholding这里是你的真实持仓的。
建议你 增加条件
if kd and tholding=0 and TISPRVREMAIN = 0 then begin
另外后台交易对编写者的编程能力要求较高,您应该懂得一些基本的调试技巧,以免出现问题后手足无措。
请认真参考
DEBUGFILE----使用日志方式完善您的策略
http://www.weistock.com/bbs/dispbbs.asp?boardid=4&Id=49428
if pk and TISPRVREMAIN(0)=0 then tSELLSHORT(1,0,mkt); //平空信号
if kd and tholding=0 and TISPRVREMAIN(0)=0 then tBUY(1,ss,mkt); //开多信号
if pd and TISPRVREMAIN(0)=0 then tSELL(1,0,mkt); //平多信号
if kk and tholding=0 and TISPRVREMAIN(0)=0 then tBUYSHORT(1,ss,mkt); //开空信号
持仓:tholding,linethick0;
今天测试了还是重复开仓了