花生网
标题:
序列数据类型的问题,急需解答!!!
[打印本页]
作者:
benyip
时间:
2013-4-11 11:21
标题:
序列数据类型的问题,急需解答!!!
本帖最后由 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的模式要怎样写?
谢谢!
作者:
xhx
时间:
2013-4-11 14:25
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
得研究一下。。
作者:
benyip
时间:
2013-4-11 15:56
貌似tick触发, variable变量不能保存,不知在策略里run_every_tick会不会这样?
作者:
hongxing1110
时间:
2013-7-8 18:34
学习学习
欢迎光临 花生网 (http://www.hs633.com/)
Powered by Discuz! X2