以文本方式查看主题

-  金字塔客服中心 - 专业程序化交易软件提供商  (http://weistock.com/bbs/index.asp)
--  公式模型编写问题提交  (http://weistock.com/bbs/list.asp?boardid=4)
----  这样的代码为啥,有时会只平不开仓呢?  (http://weistock.com/bbs/dispbbs.asp?boardid=4&id=66968)

--  作者:qq代人发帖
--  发布时间:2014/7/4 16:02:41
--  这样的代码为啥,有时会只平不开仓呢?
请教:ss:EXTGBDATA(\'ss\'),linethick0;
if r1>=1 and t1 and dt<=2 then
 begin
  if kd then
   begin
    if hold<0 then begin
     tsellshort(1,1,mkt,0,0);
     hold:=0;
    end
    if hold=0 then begin
     tbuy(tholding<ss,1,mkt,0,0);
     hold:=1;
    end
   end
  if kk then
   begin
    if hold>0 then begin
     tsell(1,1,mkt,0,0);
     hold:=0;
    end
    if hold=0 then begin
     tbuyshort(-tholding<ss,1,mkt,0,0);
     hold:=-1;
    end
   end
 end 

--  作者:jinzhe
--  发布时间:2014/7/4 16:26:34
--  

有3个条件

kk,  hold=0, -tholding<ss

其中有一个不成立


--  作者:Ivan
--  发布时间:2014/7/4 23:11:55
--  
以下是引用jinzhe在2014/7/4 16:26:34的发言:

有3个条件

kk,  hold=0, -tholding<ss

其中有一个不成立

kk肯定成立的,

hold=0也是肯定,因为假如hold>0,则会进入平仓后赋值hold:=0的,

至于-tholding<ss,也是成立的,ss:=20,而当时的-tholding还远小于20,还在10以下呢!


--  作者:jinzhe
--  发布时间:2014/7/7 9:32:19
--  

不要那么肯定,有一个不成立,不要怀疑计算机的计算能力

你用debugfile调试输出一下各个条件