以文本方式查看主题

-  金字塔客服中心 - 专业程序化交易软件提供商  (http://weistock.com/bbs/index.asp)
--  公式模型编写问题提交  (http://weistock.com/bbs/list.asp?boardid=4)
----  关于后台网格交易模型  (http://weistock.com/bbs/dispbbs.asp?boardid=4&id=138218)

--  作者:安天步
--  发布时间:2016/8/18 14:14:36
--  关于后台网格交易模型
input:grid(20,1,60,10);
variable:level=0;
oo:CALLSTOCK(\'ic08\',VTopen,6,0);
cc:=callstock(\'ic08\',vtclose,1,0);


if time=093100 and cc>oo then 
begin 
 tbuy(1,1,mkt); 
 level:=level+1;
 upprice:=oo+level*grid;
 DNPRICE:=oo+(level-1)*grid;
end
if time=093100 and cc<=oo then 
begin
 tbuyshort(1,1,mkt);
 level:=0;
 upprice:=oo+level*grid;
 DNPRICE:=oo+(level-1)*grid;
end 

上多:=tbuyholding(1)>0 and cc>=upprice;
下多:=tbuyholding(1)>0 and dnprice>cc;
t1:=cc>=upprice;

 if 上多 then
  begin
  level:=level+1;
  upprice:=oo+level*grid;
  DNPRICE:=oo+(level-1)*grid; 
  end
 
 if 下多 then
  begin
  PD:tsell(1,tholding,mkt);
  KK:tbuyshort(1,1,mkt);
  level:=level-1;
  upprice:=oo+level*grid;
  DNPRICE:=oo+(level-1)*grid; 
  end
  
if time=closetime(0) and tbuyholding(1)>0 then
tsell(1,tholding,mkt);

上空:=tsellholding(1)>0 and cc>=upprice;
下空:=tsellholding(1)>0 and cc<DNPRICE;

 if 上空 then
  begin
  PK:tsellshort(1,tholding,mkt);
  KD:tbuy(1,1,mkt);
  level:=level+1;
  upprice:=oo+level*grid;
  DNPRICE:=oo+(level-1)*grid; 
  end
 
 if 下空 then
  begin
  level:=level-1;
  upprice:=oo+level*grid;
  DNPRICE:=oo+(level-1)*grid; 
  end

if time=closetime(0) and tsellholding(1)>0 then
tsellshort(1,tholding,mkt);


debugfile(\'d:\\test后台.txt\',\'tbuyholding(1) = %.2f\',tbuyholding(1));
debugfile(\'d:\\test后台.txt\',\'tsellholding(1) = %.2f\',tsellholding(1));
debugfile(\'d:\\test后台.txt\',\'cc = %.2f\',cc);
debugfile(\'d:\\test后台.txt\',\'upprice = %.2f\',upprice);
debugfile(\'d:\\test后台.txt\',\'DNPRICE = %.2f\',DNPRICE);
debugfile(\'d:\\test后台.txt\',\'上多 = %.2f\',上多);
debugfile(\'d:\\test后台.txt\',\'下多 = %.2f\',下多);
debugfile(\'d:\\test后台.txt\',\'上空 = %.2f\',上空);
debugfile(\'d:\\test后台.txt\',\'下空 = %.2f\',下空);
debugfile(\'d:\\test后台.txt\',\'level = %.2f\',level);

金哲老师,请您帮忙看看这个公式哪里有问题?我个人看到是LEVEL一直没变过,是不是全局变量设置有问题?
 下载信息  [文件大小:   下载次数: ]
点击浏览该文件:test后台.txt


--  作者:jinzhe
--  发布时间:2016/8/18 14:17:29
--  

variable这个是图表全局变量

后台全局变量用globalvariable,每次关闭交易后再启动时重置为初值


--  作者:安天步
--  发布时间:2016/8/18 14:28:07
--  
原来是这样啊,这2个函数没解释清楚。