以文本方式查看主题

-  金字塔客服中心 - 专业程序化交易软件提供商  (http://weistock.com/bbs/index.asp)
--  公式模型编写问题提交  (http://weistock.com/bbs/list.asp?boardid=4)
----  关于超全局变量,晕了  (http://weistock.com/bbs/dispbbs.asp?boardid=4&id=78612)

--  作者:roadpeace
--  发布时间:2015/5/14 17:22:12
--  关于超全局变量,晕了
以下代码有何问题??这超全局变量,弄晕了
我自己看来extgbdata(\'buypart\'),应该和holding一致才对。
根据输出,holding开多或空的时候会变一下,然后又变成0。不明其中奥妙


runmode:0;

aaa:=ref(count(c>o,2),1)=2;
bbb:=ref(count(c<o,2),1)=2;
  if islastbar then begin
  if extgbdata(\'buypart\')<0 && aaa then begin
    sellshort(1,0,thisclose);
    extgbdataset(\'buypart\',0);
   msgout(1,\'平空\');
  end
  if extgbdata(\'buypart\')>0 && bbb then begin
    sell(1,0,thisclose);
    extgbdataset(\'buypart\',0);
   msgout(1,\'平多\');
  end

  if extgbdata(\'buypart\')=0 && aaa then begin
    buy(1,1,thisclose);
    extgbdataset(\'buypart\',1);
   msgout(1,\'开多\');
  end
  if extgbdata(\'buypart\')=0 && bbb then begin
    BUYSHORT(1,1,thisclose);
    extgbdataset(\'buypart\',-1);
   msgout(1,\'开空\');
  end

    msgout(1,\'buypart:\' & numtostr(extgbdata(\'buypart\'),0)&\';holding:\' & numtostr(holding,0));
  end;
 



以下是部分输出
------------------------------------------------------------
2015/05/14 17:16:51  buypart:-1;holding:0
2015/05/14 17:16:54  buypart:-1;holding:0
2015/05/14 17:16:58  平空
2015/05/14 17:16:58  开多
2015/05/14 17:16:58  buypart:1;holding:1
2015/05/14 17:16:59  buypart:1;holding:0
2015/05/14 17:17:01  buypart:1;holding:0
2015/05/14 17:17:04  buypart:1;holding:0


--  作者:roadpeace
--  发布时间:2015/5/14 18:30:22
--  
想了一下,是不是因为逐K模式,从头刷了一次,把holding搞成0了?
以buypart=1为例,从头刷一次,只可能触发平多,所以holding变0了

那,是不是说如果要buypart和holding相同,只能是后台交易的序列模式
这后台没权限我也不知道后台的序列模式是不是这样?!
反正有点头晕

--  作者:jinzhe
--  发布时间:2015/5/15 8:47:23
--  
不要在图表里面使用extgb,没有历史记录,