if(Mod(CurrentBar, 10) == 1) nnn = CurrentBar; //nnn是全局整数型变量
Numeric a1;
Numeric a2;
Numeric a3;
Numeric a4;
LinearReg(H, 5, 0, a1, a2, a3, a4);
Commentary(Text(a4));
Numeric b1;
Numeric b2;
Numeric b3;
Numeric b4;
Integer aaa = CurrentBar-nnn+1;
Commentary(Text(aaa));
LinearReg(H, aaa, 0, b1, b2, b3, b4);
Commentary(Text(b4)); //当aaa=5的时候,理论上来说应该和b4=a4,但是两者不一致
//使用了自己修改过的函数
Numeric c1;
Numeric c2;
Numeric c3;
Numeric c4;
Integer bbb = CurrentBar-nnn+1;
Commentary(Text(bbb));
sssssss(H, bbb, 0, c1, c2, c3, c4);
Commentary(Text(c4)); //修改函数后,当bbb=5,c4=a4,没问题!
官方的线性回归代码,复制出来,编译会报警告信息,同时导致在某些情况下数据计算不对!!!比如上述情况,修改后,数据正常!!!
修改后的LinearReg函数如下:
我试了好几遍,但是用if(length <=1) return false;貌似仍然不行。 只有去掉if条件,数据就正常!!!
我刚才修改了下内置函数,
这样即便用变量,数据也是对的
length参数不能填变量
不对,修改的应该是 if(length <= 1),上图写错了