欢迎使用金字塔普通技术服务论坛,您可以在相关区域发表技术支持贴。
我司技术服务人员将优先处理 VIP客服论坛 服务贴,普通区问题处理速度慢,请耐心等待。谢谢您对我们的支持与理解。


金字塔客服中心 - 专业程序化交易软件提供商金字塔软件公式模型编写问题提交 → 循环问题求教

   

欢迎使用金字塔普通技术服务论坛,您可以在相关区域发表技术支持贴。
我司技术服务人员将优先处理 VIP客服论坛 服务贴,普通区问题处理速度慢,请耐心等待。谢谢您对我们的支持与理解。    


  共有3089人关注过本帖平板打印复制链接

主题:循环问题求教

帅哥哟,离线,有人找我吗?
Prongs
  1楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:新手上路 帖子:17 积分:0 威望:0 精华:0 注册:2015/9/14 10:52:05
循环问题求教  发帖心情 Post By:2015/9/24 10:42:08    Post IP:115.236.13.58[只看该作者]

写了一个网格交易的模型,单行执行没有问题,但是改成循环语句就出问题了,感觉好像不是完全执行完第一个循环再去执行第二个循环,而是整体在执行循环,请问是哪里出了问题?

 

单行是可以执行的:

input: P(2600,0,50000,1), J(3,1,10,1),N(10,1,100,1); //初始价格,网格宽度,每笔手数


 

if TREMAINQTY(1,'','')<=0*n then
tbuy(c>=p-9*j&&tholding2<=9*n,n,lmt,p-9*j);

if TREMAINQTY(1,'','')<=1*n then
tbuy(c>=p-8*j&&tholding2<=8*n,n,lmt,p-8*j);

if TREMAINQTY(1,'','')<=2*n then
tbuy(c>=p-7*j&&tholding2<=7*n,n,lmt,p-7*j);

if TREMAINQTY(1,'','')<=3*n then
tbuy(c>=p-6*j&&tholding2<=6*n,n,lmt,p-6*j);

if TREMAINQTY(1,'','')<=4*n then
tbuy(c>=p-5*j&&tholding2<=5*n,n,lmt,p-5*j);

 

if TREMAINQTY(1,'','')<=5*n then
tbuy(c>=p-4*j&&tholding2<=4*n,n,lmt,p-4*j);

if TREMAINQTY(1,'','')<=6*n then
tbuy(c>=p-3*j&&tholding2<=3*n,n,lmt,p-3*j);

if TREMAINQTY(1,'','')<=7*n then
tbuy(c>=p-2*j&&tholding2<=2*n,n,lmt,p-2*j);

if TREMAINQTY(1,'','')<=8*n then
tbuy(c>=p-j&&tholding2<=n,n,lmt,p-j);

if TREMAINQTY(1,'','')<=9*n then
tbuy(c>=p&&tholding2<=0,n,lmt,p);

 

if TREMAINQTY(4,'','')<=9*n then
tsell(c<=p-8*j&&tholding2>=10*n,n,lmt,p-8*j);

if TREMAINQTY(4,'','')<=8*n then
tsell(c<=p-7*j&&tholding2>=9*n,n,lmt,p-7*j);

if TREMAINQTY(4,'','')<=7*n then
tsell(c<=p-6*j&&tholding2>=8*n,n,lmt,p-6*j);

if TREMAINQTY(4,'','')<=6*n then
tsell(c<=p-5*j&&tholding2>=7*n,n,lmt,p-5*j);

if TREMAINQTY(4,'','')<=5*n then
tsell(c<=p-4*j&&tholding2>=6*n,n,lmt,p-4*j);


if TREMAINQTY(4,'','')<=4*n then
tsell(c<=p-3*j&&tholding2>=5*n,n,lmt,p-3*j);

if TREMAINQTY(4,'','')<=3*n then
tsell(c<=p-2*j&&tholding2>=4*n,n,lmt,p-2*j);

if TREMAINQTY(4,'','')<=2*n then
tsell(c<=p-j&&tholding2>=3*n,n,lmt,p-j);

if TREMAINQTY(4,'','')<=1*n then
tsell(c<=p&&tholding2>=2*n,n,lmt,p);

if TREMAINQTY(4,'','')<=0*n then
tsell(c<=p+j&&tholding2>=n,n,lmt,p+j);

 

循环执行会出现问题:

input: P(2600,0,50000,1), J(3,1,10,1),N(10,1,100,1),M(10,1,30,1); //初始价格,网格宽度,每笔手数,网格数量

FOR i=1 TO M DO

if TREMAINQTY(1,'','')<=(i-1)*n then
tbuy(c>=p-(10-i)*j&&tholding2<=(10-i)*n,n,lmt,p-(10-i)*j);

FOR u=1 TO M DO

if TREMAINQTY(4,'','')<=(10-u)*n then
tsell(c<=p-(9-u)*j&&tholding2>=(11-u)*n,n,lmt,p-(9-u)*j);

 


 


 回到顶部