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

Re: sve.lr function



PureBytes Links

Trading Reference Links

At 06:30 PM 7/3/2004, Alex Matulich wrote:

>You mean it assumes the current bar corresponds to X=0.  This is
>merely a convenient way to get the value of the regression line
>at the current bar.  Once you have the slope, you can make the Y
>intercept any place you want.  Defining it at the currentbar is
>simply a convenience.

No. The version you referenced allows only one price input and returns the linear regression coefficients of that price stream vs. CurrentBar.

My version allows two price inputs, typically as Close data1 and Close data2.
It calculates the linear regression coefficients between those two inputs. neither of which has to be CurrentBar.

>>Below is listed my function for doing this. It uses all the tricks I know of 
>>to improve accuracy and speed. It also returns the standard error value in 
>>addition to the slope and intercept. I have tested it on TS 8 but not on 
>>TS2000i.
>
>Thanks.  By the way, in my tests of this sort of thing, I found that
>you can easily recalculate the loop every 1000 bars instead of 100
>bars.  At 1000 bars, the accumulated error is so insignificant, one
>doesn't notice.

Probably true. I tested it with TS 8 and with the double-precision arithmetic, there were no noticeable errors even without the error reduction tricks - brute force would have worked fine. The time difference between correcting every 100 vs. every 1000 bars would be extremely small in any case.

But this version is very much faster than the brute force version...

Bob