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

Re: Linear Reg Value input problem



PureBytes Links

Trading Reference Links

Just a little modification of an "old" Omega function.

Watch out you do not ask for the length to get too long or you
will be waiting quite a while if it ever finishes.

Clyde



{*******************************************************************
Description: Linear_Regr_Value2
Provided By: Omega Research, Inc. (c) Copyright 1999
Modified By: Clyde Lee
********************************************************************}

Inputs: Price(NumericSeries), Len(NumericSimple), TargetB(NumericSimple);
Variables: X(0), Num1(0), Num2(0), SumBars(0), SumSqrBars(0), SumY(0),
Sum1(0), Sum2(0), Slope(0), Intercept(0);

If Len = 0 Then begin
  Linear_Regr_Value2 = Price;
End
Else begin

SumBars = 0;
SumSqrBars = 0;
SumY = 0;
Sum1 = 0;
Sum2 = 0;
SumY = Summation(Price, Len);
SumBars = Len * (Len - 1) * .5;
SumSqrBars = (Len - 1) * Len * (2 * Len - 1) / 6;

For X = 0 To Len - 1 Begin
 Sum1 = Sum1 + X * Price[X];
End;

Sum2 = SumBars * SumY;
Num1 = Len * Sum1 - Sum2;
Num2 = SumBars * SumBars - Len * SumSqrBars;

If Num2 <> 0  Then
 Slope = Num1 / Num2
Else
 Slope = 0;

Intercept = (SumY - Slope * SumBars) / Len;

Linear_Regr_Value2 = Intercept + Slope * (Len - 1 + CurrentBar - BarNumber -
TargetB);

END;
- - - - - - - - - - - - - - - - - - - - -  - - - - - - -
Clyde Lee   Chairman/CEO          (Home of SwingMachine)
SYTECH Corporation    email:clydelee@xxxxxxxxxxxxxxxxxxx
7910 Westglen, Suite 105       Office:    (713) 783-9540
Houston,  TX  77063               Fax:    (713) 783-1092
Details at:                      www.theswingmachine.com
- - - - - - - - - - - - - - - - - - - -  - - - - - - - -

----- Original Message -----
From: "Ian Waugh" <ianwaugh@xxxxxxxxx>
To: <omega-list@xxxxxxxxxx>
Cc: <ianwaugh@xxxxxxxxxxxxxxxxxxx>
Sent: Tuesday, August 27, 2002 4:24 PM
Subject: Linear Reg Value input problem


> Hi All,
>        I'd like to calculate the LinearRegValue, changing the value of
> Length on a bar by bar basis. The code would be something like:
>
> Len=0;
> Len=Len+1;
> plot1(LinearRegValue(close,Len,TargetB);
> etc...
>
> However, you cannot alter the value of Len for LinearRegValue on a bar
> by bar basis.
>
> Any ideas how I can do this?
>
> Cheers,
> Ian
>