Regression channel broken (build 194)

 
Slope of the regression line is completely off now, in build 194 (I can post a screenshot if neccessary).

Also, I think, build 193 (or lower) was calclulating the standard deviation from the regression line incorrectly; I wrote my own regression channel code and I couldn't get the same deviation, although I'm pretty certain my code is correct (I did extensive testing).
 
Please download again. This bug is fixed
 
Slope of the regression line is completely off now, in build 194 (I can post a screenshot if neccessary).

Also, I think, build 193 (or lower) was calclulating the standard deviation from the regression line incorrectly; I wrote my own regression channel code and I couldn't get the same deviation, although I'm pretty certain my code is correct (I did extensive testing).


Hi SuperBug,

I tried to make work the code as published at "Linear Regression Channel, Calculating Method" and have ran into the same problem like you.
Can you post your code?
Thanks.
 
Please download terminal dated 16 Jun
There was error of calculating of second price value. Right update is:
   int n=m_pos[1]-m_pos[0]+1;
//---- calculate price values
   double value=Close[m_pos[0]];
   double a,b,c;
   double sumy=value;
   double sumx=0.0;
   double sumxy=0.0;
   double sumx2=0.0;
   for(i=1; i<n; i++)
     {
      value=Close[m_pos[0]+i];
      sumy+=value;
      sumxy+=value*i;
      sumx+=i;
      sumx2+=i*i;
     }
   c=sumx2*n-sumx*sumx;
   if(c==0.0) return;
   b=(sumxy*n-sumx*sumy)/c;
   a=(sumy-sumx*b)/n;
   m_value[0]=a;
   m_value[1]=a+b*(n-1);
//---- maximal deviation
   double maxdev=0;
   double deviation=0;
   double dvalue=a;
   for(i=0; i<n; i++)
     {
      value=Close[m_pos[0]+i];
      dvalue+=b;
      deviation=fabs(value-dvalue);
      if(maxdev<=deviation) maxdev=deviation;
     }


m_value[1]=a+b*(n-1);

 
Please download terminal dated 16 Jun
There was error of calculating of second price value. Right update is:

m_value[1]=a+b*(n-1);

Thanks Slawa!
 
It works correctly now. Both, the slope and the standard deviation. Thanks!

(Sub: I believe you got the code you asked for from Slawa. )