欢迎您光临花生网社区!
| |

 找回密码
 立即注册
查看: 2678|回复: 3
打印 上一主题 下一主题

序列数据类型的问题,急需解答!!! [复制链接]



Rank: 6Rank: 6

跳转到指定楼层
1#
发表于 2013-4-11 11:21:22 |只看该作者 |倒序浏览 | [分享到 腾讯微博 新浪微博]
本帖最后由 benyip 于 2013-4-11 11:22 编辑

请问:我猜软件里价格序列的数据类型应该是浮点数,(从DLL数据结构定义也可以看出),如果在技术指标公式里或策略里判断两个价格的大小关系(大,小,相等),如何保证比较正确?或者软件底层是如何处理的?

还有时间函数time返回的是整型还是浮点型?

#Run_By_Bar
New_Time := 0;
if New_Time == time[0]/100 then
begin
   Print(New_Time, '++',time[0]/100);
   exit;  
end;

ma1: Average(c,5);
New_Time := Time[0]/100;
Print(New_Time, '--',time[0]/100);

如上所示,为何永远都执行不到if里的语句?
是因为那个条件都是浮点数,不能完全相等吗?
如果要在指标里实行类似run_every_bar的模式要怎样写?
谢谢!

使用道具 举报



vip

Rank: 9Rank: 9Rank: 9

2#
发表于 2013-4-11 14:25:56 |只看该作者 | [分享到 腾讯微博 新浪微博]
1,判断相等的话,可以用ROUND函数把精度搞到一致
2,time 取的是K线的时分秒,在日线及以上周期,time都返回0,

试下这个公式在1分钟,周线上跑的log

#Run_By_Bar
variable:New_Time(0);
//New_Time := 0;
Print('##',New_Time);
Print('&&',time/100);
if New_Time = time/100 then
begin
   Print(New_Time, '++',time/100);
   exit;  
end;

ma1: Average(c,5);
New_Time := Time/100;
Print(New_Time, '--',time/100);


然后就知道原因了。我也是发现的,至于为啥还没搞明白。

log:
11-14:25:14  testsell 输出:##1424

11-14:25:14  testsell 输出:&&1425

11-14:25:14  testsell 输出:1425--1425

11-14:25:14  testsell 输出:##1424

11-14:25:14  testsell 输出:&&1425

11-14:25:14  testsell 输出:1425--1425

11-14:25:15  testsell 输出:##1424

11-14:25:15  testsell 输出:&&1425

11-14:25:15  testsell 输出:1425--1425

11-14:25:15  testsell 输出:##1424

11-14:25:15  testsell 输出:&&1425

11-14:25:15  testsell 输出:1425--1425

11-14:25:16  testsell 输出:##1424

11-14:25:16  testsell 输出:&&1425

11-14:25:16  testsell 输出:1425--1425

11-14:25:16  testsell 输出:##1424

11-14:25:16  testsell 输出:&&1425

11-14:25:16  testsell 输出:1425--1425


为啥
11-14:25:16  testsell 输出:##1424

11-14:25:16  testsell 输出:&&1425
得研究一下。。

使用道具 举报



Rank: 6Rank: 6

3#
发表于 2013-4-11 15:56:07 |只看该作者 | [分享到 腾讯微博 新浪微博]
貌似tick触发, variable变量不能保存,不知在策略里run_every_tick会不会这样?

使用道具 举报



Rank: 3Rank: 3

4#
发表于 2013-7-8 18:34:45 |只看该作者 | [分享到 腾讯微博 新浪微博]
学习学习

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册


bottom

Archiver|www.hs633.com ( 粤ICP备11107430号 )

GMT+8, 2024-5-5 14:55 , Processed in 0.093750 second(s), 8 queries .

花生网 Copyright©2012-2014

回顶部