If you run the example from the Wiki link in your first post, you'll see that for a fixed period the channel changes slope with each successive bar, following the LinReg line (which isn't plotted in the example). To use a channel in the way you're probably thinking, you have to identify a period of interest and then extend the channel (until it's not useful anymore). This is not unlike creating a trading system with trendlines - it's beyond the scope of the Strategy Builder because it's a fairly complex coding effort that requires a lot of housekeeping.

I was thinking about calculating each day all possible regression lines between n=30 and n=350 days and R² for each regression line too. I would then choose the regression line with the highest R² and a positive slope as entering rule.

To exit I would look for the regression line with the highest R² and a negative slope. Or when the stock leaves the index.

The logic is to identify the LR lines is pretty straightforward, but...

1. After you find the reg line with the highest R², what triggers the entry? R² aside, price is going to be either above or below the linear reg indicator, which is the last point in the associated LR line. Would you buy if the price is higher or lower than the LR indicator?

2. The thread's topic is about LR Channels. Maybe your trade trigger is when price is within some distance of the upper or lower channel?

If less than half of the maximum possible positions are actually open I want to close all positions. Entry signals shall just be penciled in until at least half of the maximum possible positions will be open. If that point is reached all entry signals shall be implemented at once. If in the meantime an exit signal was triggered the corresponding entry signal will not be valid anymore.

1. Remove the mutual exclusion between the exit and entry logic. (comment out the "else")2. Create and manage a List<int> that holds the period, n, for each signal. 3. When there's signal, add it to the list. 4. On each bar, loop through the signal list checking if the slope has fallen below zero. If it has, remove it from the list. 5. On each bar, check if the List.Count is greater than half some maxSignals constant. If it is, buy the positions. 6. Thereafter as more signals occur up to the max, you buy the positions immediately.7. When the List.Count falls below maxPositions / 2, exit Positions.AllPositions

You'll probably need to add a little hysteresis so that once you put on half your positions, they're not all exited on the next bar because only one of the signals is no longer valid.

Just reviewing the code that I gave you, it probably should check that the LinearRegSlope is greater than zero as condition to enter the trade. If it is not, the trade will be exited immediately even though RSquared > 90%.

We sent an Verification
Code to your email address. If you don't receive this code within the next 5 minutes.
Please click here to
request a new code.
New Verification Code sent. Please check your Inbox.Please enter your Email to receive a new Verification Code