以文本方式查看主题

-  金字塔客服中心 - 专业程序化交易软件提供商  (http://weistock.com/bbs/index.asp)
--  公式模型编写问题提交  (http://weistock.com/bbs/list.asp?boardid=4)
----  请教程序执行过程中的数据矛盾  (http://weistock.com/bbs/dispbbs.asp?boardid=4&id=139966)

--  作者:daviwang
--  发布时间:2016/9/23 10:23:04
--  请教程序执行过程中的数据矛盾
在逐k模式中,公式运行变量查看器中的数据矛盾.具体如下:


程序内容
Variable:fk=0;
nn:=barslast(date<>ref(date,1))+1;
h5:=valuewhen(nn=5,hhv(h,nn));
L5:=valuewhen(nn=5,llv(l,nn));
a:=c-h5+mindiff;
b:=c-l5-mindiff;
If a>0 then fk:=1;
If b<0 then fk:=-1;
If nn>15 then fk:=0;


测试品种为RU13,时间为2016-09-01到2016-09-23.


在16/09/19 09:05:00时,公式运行变量查看器中的数据如下:
wwma1 时间:16/09/19 09:05:00 序列:5113  FK: 1.000 NN: 5.000 H5: 12344.000 L5: 12175.000 A: -116.000 B: 43.000 MA15: 12281.467 


a<0,fk的计算结果应该为0.为何公式运行变量查看器中的fk=1  ?

--  作者:jinzhe
--  发布时间:2016/9/23 10:31:09
--  
你代码里面,并没有 在a<0时,fk赋值为0的代码
--  作者:daviwang
--  发布时间:2016/9/23 10:38:05
--  
这样修改可以吗?
Variable:fk=0;
nn:=barslast(date<>ref(date,1))+1;
h5:=valuewhen(nn=5,hhv(h,nn));
L5:=valuewhen(nn=5,llv(l,nn));
a:=c-h5+mindiff;
b:=c-l5-mindiff;
If a>0 then fk:=1;
if a<=0 then fk:=0;
If b<0 then fk:=-1;
if b>=0 then fk:0;
If nn>15 then fk:=0;

--  作者:jinzhe
--  发布时间:2016/9/23 10:41:15
--  
if b>=0 then fk:0;
这句要
if b>=0 then fk:=0;
 
其他都可以

--  作者:jinzhe
--  发布时间:2016/9/23 10:41:32
--  
要想清楚在什么情况下要怎么赋值,
--  作者:daviwang
--  发布时间:2016/9/23 10:42:17
--  
明白了,谢谢!