[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: old TS linear regression ...



PureBytes Links

Trading Reference Links

Got it, thanks all!


----- Original Message ----- From: "jim f." <bigbubber@xxxxxxxxx>
To: "Chris Cheatham" <chris_c@xxxxxxxxxx>
Sent: Saturday, August 25, 2007 10:08 AM
Subject: Re: old TS linear regression ...


----- Original Message ----- From: "Chris Cheatham" <chris_c@xxxxxxxxxx>
To: "Omega List" <omega-list@xxxxxxxxxx>
Sent: Friday, August 24, 2007 9:26 PM
Subject: old TS linear regression ...


Hi gang,

Anyone out there have the old TS 4/2000i (pre TS 8 "multi-output") linear
regression curve function? I want to make a modification to it, but would
rather not navigate thru all the multi-output silliness if not necessary.
Text is fine.

Mny thanks,
Chris


dunno if these will help.. hope so.
i didn't see one for "curve"
had slope - line

{*******************************************************************
Description : This Function returns Linear Regression Line
Provided By : Omega Research, Inc. (c) Copyright 1999
********************************************************************}

Inputs: Length(Numeric), BarsPlus(Numeric), SlctDate(Numeric),
SlctTime(Numeric), Color(Numeric), ExtRight(TrueFalse);
Variables: LRV(0), LRVAgo(0), TLLRV(0), Flag(0);

LRV = LinearRegValue(Close, Length, BarsPlus);
LRVAgo = LinearRegValue(Close, Length, Length-1);

If LastBarOnChart AND SlctDate = 0 AND Flag = 0 Then Begin
TLLRV = TL_New(Date[Length-1], Time[Length-1], LRVAgo, Date, Time, LRV);
Flag = 1;
End;
If Date = SlctDate AND (Time = SlctTime OR SlctTime = 0) Then Begin
TLLRV = TL_New(Date[Length-1], Time[Length-1], LRVAgo, Date, Time, LRV);
Flag = 2;
End;
If Flag = 1 OR Flag = 2 Then Begin
If Flag = 2 Then
 Flag = 3;
TL_SetColor(TLLRV, Color);
TL_SetExtLeft(TLLRV, False);
If ExtRight Then
 TL_SetExtRight(TLLRV, True)
Else
 TL_SetExtRight(TLLRV, False);
End;

If Flag = 1 Then Begin
TL_SetBegin(TLLRV, Date[Length-1], Time[Length-1], LRVAgo);
TL_SetEnd(TLLRV, Date, Time, LRV);
End;

If LRV <> -1 Then
LinearRegLine = 1
Else
LinearRegLine = -1;

{*******************************************************************
Description: Linear Regression Slope
Provided By: Omega Research, Inc. (c) Copyright 1999
********************************************************************}

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;

{*******************************************************************
Description: Linear Regression Slope (fast calculation)
Provided By: Omega Research, Inc. (c) Copyright 1999
********************************************************************}

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
LinearRegSlopeFC = 0;

If CurrentBar = 1 Then Begin
SumBars = SumBars[1];
SumBars = Len * (Len - 1) * .5;
SumSqrBars = (Len - 1) * Len * (2 * Len - 1) / 6;
End;

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
LinearRegSlopeFC = Num1 / Num2
Else
LinearRegSlopeFC = 0;