Announcement

Collapse
No announcement yet.

LinearRegSlope() TS function

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • LinearRegSlope() TS function

    Does anybody have an equivilant version of the TS LinearRegSlop() function? Or can someone post the text of the TS LinearRegSlope() function from TS so that I can translate it to a efs function?

  • #2
    bpschoch
    Enclosed below is the TS code
    Alex

    Code:
    Inputs: Price(NumericSeries), Len(NumericSimple);
    Variables: X(0), Num1(0), Num2(0), SumBars(0), SumSqrBars(0), SumY(0), Sum1(0), Sum2(0);
    
    If Len = 0 Then
    	LinearRegSlope=0;
    
    SumBars = Len * (Len - 1) * .5;
    SumSqrBars = (Len - 1) * Len * (2 * Len - 1) / 6;
    Sum1 = 0;
    
    For X = 0 To Len - 1 Begin
    	Sum1= Sum1 + X * Price[X];
    End;
    
    SumY = Summation(Price, Len);
    Sum2 = SumBars * SumY;
    Num1 = Len * Sum1 - Sum2;
    Num2 = SumBars * SumBars - Len * SumSqrBars;
    
    If Num2 <> 0 Then 
    	LinearRegSlope = Num1 / Num2
    Else 
    	LinearRegSlope = 0;

    Comment

    Working...
    X