Does Anyone Know How to Express Linear Regression Channel Lines as a Strategy/Signal Component in EasyLanguage
December 13th, 2009I’ve been trying to convert code from a linear regression channel indicator into a strategy. I haven’t been able to figure out how to do it.
In short, what I want to be able to do is buy when:
Close is less than the lower channel line (I have no idea how to express this), plus some other snake oil.
This is the code that’s drawing the lower channel line:
TLLRVLO = TL_New(Date[Length - 1], Time[Length-1],LRVAgo-IFF(StdErrEnv<AvgStdErr,StdErrEnv,AvgStdErr),Date,Time,LRV-IFF(StdErrEnv<AvgStdErr,StdErrEnv,AvgStdErr));
Here’s the complete indicator.
I’m not committed to using the indicator code that I’ve mentioned here. LinearRegFC works well, but it’s just the centerline. What’s the easiest way to express the upper and lower channel lines? I suspect that is has something to do with StdError, but I’m not able to figure it out.
Bonus problem #1: Normally, the linear regression indicators draw the lines from the last bar (or some offset from the last bar) of the data series. This is fine for realtime use, but not so good for backtesting. When I’ve been writing strategies using LinearRegFC, the calculations work fine, but I haven’t figured out how to make it draw the linear regression JUST from the entry bar backward. It would be really nice to see the state of the linear regression when the strategy enters a trade.
Bonus problem #2: In LinearRegFC(Price, Length, TgtBar, oLRSlope, oLRAngle, oLRIntercept, oLRValue), where oLRAngle is the linear regression line angle in terms of degrees, uhhhh, how the *bleep* do you express the degrees? I became so baffled by this that I plotted the output of oLRAngle as an indicator and it comes out like this: .abcd. So, does an oLRAngle value of .1357 mean +13.57 degrees? Down sloping lines come out -.abcd, so I’m assuming that’s right. Does anyone know?

You probably figured that out, but in case it’s of any use :
StdError stands for standard error (= square root[variance], variance being the sum of the squared differences to the mean value, divided by the number of units).
The standard error is basically an indicator of the differences to the mean. I guess in your case it’s used to display nicely fitting upper and lower channels, so you probably can try your own : just add or remove some fudge factor (including the StdError, why not ?) to the y-intercept of the linear_regression equation and you’ll get err.. something.
Cryptogon reader anothernut supplied me with some helpful code. Thanks.