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

Re: Linear regression indicator in ELA



PureBytes Links

Trading Reference Links

>I am still running SC 4.0 (which uses the TS 4.0 EL code)
>
>I am looking for an indicator that would plot a straight linear
>regression line between 2 points.  One input would be price, and
>another the length.  It would also be great to have the ability to
>plot straight sigma SD band lines above and below the LR line

That's not a linear regression.  That's just a line connecting 2 points.
The formula for that is easy.

The slope is:      m = (y1 - y2) / (x1 - x2)
The intercept is:  b = y1 - m*x1  -or-  b = y2 - m*x2

where x1,y1 and x2,y2 are your endpoints (where y is in price units and
x is in time units).

Formula for a line is y = mx + b

Your specifications aren't clear as to what you want.  Just 2
inputs, price and length?  Do you mean the first endpoing is the
price on the current bar and the second endpoint is the price at
length bars back?  You don't need a regression for that, or even
a formula for a line.  You just need to draw a trendline, with
TL_New() and other TL_ functions.

-- 
  ,|___    Alex Matulich -- alex@xxxxxxxxxxxxxx
 // +__>   Director of Research and Development
 //  \     Unicorn Research Corporation -- http://unicorn.us.com 
 // __)    HTML FORMATTED MAIL SENT HERE WILL BE REJECTED AS SPAM.