User-Interactive Linear Regression Channel Indicator: LRChan

Fig. 1. Bollinger Ribbons. Centerline is AMA, deviation is StdDev units.
The Deviation Function is User Selectable
- Standard Deviation
- Standard Error
- Average True Range – ATR (Keltner Bands)
- Jurik Average True Range JATR (ATR using Jurik Moving Average)
- Percentage
- Points
- Standard Deviation (Bollinger Bands)
- Standard Error (Jon Andersen Bands)
- Average True Range – ATR (Keltner Bands)
- Jurik Average True Range JATR (ATR using Jurik Moving Average)
- Percentage
- Points
User-Interactive Feature
LRChan Indicator Examples
The LRChan indicator is initially applied with default input settings of Length = 60, Deviation = 1 ATR, Offset = 1.



Wishing to analyze the sideways moving segment starting at the beginning of August, the user again moves the beginning of the center line to correspond to the beginning of the sideways movement.

When the next data tick arrives, the chart again recognizes that the center line has been moved by the user and redraws the regression channel to conform to the new center line position, corresponding to Length = 21.

Now, wishing to look at the regression channel during a previous downtrend, the user clicks on the central portion of the center line and drags the entire center line to the left to correspond to the desired time segment of the chart.


When input parameter BandAlert = 3, the third deviation bands of the indicator will change to a dotted line to remind the user that the Alert is ON. In this state, the alert will be triggered when the price touches either of the 3rd bands, signifying that the price is breaking out of the previous trend. Note that the right most point of the center line is offset 6 bars to left. This is to remove the influence of the most recent bars from changing the slope or spacing of the indicator when a breakout is starting. Such a setting causes the alert from a price break out to be triggered sooner, since the indicator is not chasing in the direction of the right most bar. |

Advantages of the Object Oriented Easylanguage Version
- The Timer object generates a “tick” every CalcSeconds, which triggers the indicator to respond to any user interactive changes in the Length, Starting Position or Ending Position of the central trend line that defines the linear regression channel. LinRegChan, the older standard EL version (TS 8.0) requires a trade “tick” for any user changes to the center line to be recognized and responded to. Therefore, during times when the market was closed and no trades were occurring, there were no user-interactive features of the indicator that worked.LRChan, the OOEL version (TS 9.0), solves this problems and responds to the user dragging the center line to a new position, or changing its length by dragging one end of the other, regardless of whether the market is trading. This is a big advantage when the user wants to see how the indicator behaved in historical sections of the chart.
- LRChan is much more efficient, as it does not have to use traditional “timer” code, which is CPU intensive, to throttle the frequency the indicator is testing to see if the center line was moved by the user. The channel drawing function, DrawLRChan, has also been replaced with a local method (subroutine) DrawLRChan that is significantly more efficient.Local methods eliminate the overhead associated with passing large numbers of parameters to a function with each function call. All variables defined in the indicator (main program) are global to all local methods and do not have to be redefined or passed in the local method.Therefore, LRChan enhances responsiveness to user interactions while improving efficiency of the code.
RibbonPlotter Input Parameters
Price is the reference value used to calculate the regression line.
Length is the desired length of the regression channel.
Offset is the number of bars the regression channel is shifted to the left from the rightmost bar displayed. Shifting the regression channel to the left will reduce the influence of the most recent bars on the slope and the deviation of the channel. This will facilitate identifying price break-outs from the channel earlier, as the channel slope will not be “chasing” the the most recent price activity.
TgtBar may be used to estimate the value of the linear regression channel into the future.
DevID selects the function to use to calculate the distance between the center line and the parallel upper and lower lines. The integer value corresponds to the input parameters immediately below it. For example, DevID = 1 for a standard deviation displacement, DevID = 2 for a standard error displacement, etc.
StdDevLength is the length that will be used for the deviation function StdDev, if the user also selects DevID = 1. If StdDevLength = 0, then Length will be used for the deviation function StdDev. If the user changes the end points of the center trend line, the new trend line length is used to calculate the standard deviation.
StdErrLength is the length that will be used for the deviation function StdError, if the user also selects DevID = 2. If StdErrLength = 0, then Length will be used for the deviation function StdErr. If the user changes the end points of the center trend line, the new trend line length is used to calculate the standard error.
NBands is the number of parallel lines above and below the center line.
StartMult is the deviation function multiple used to establish the deviation used for the inner most parallel line adjacent to the center line.
Increment is the deviation function multiple used to establish spacing between all subsequent bands up to the total of NBands.
FreezeBeginPoint is set to true if the beginning point of the channel should not move when new bars are added to the chart. This is useful if the user wishes to move the channel to a pivot point representing the beginning of trend. As the trend continues, the beginning bar for the trend remains constant instead of the entire channel moving one bar to the right each time a new bar is added to the chart.
BeginDate_YYYYMMDD, if specified, sets the begining date of the LR channel, overriding the begin date normally calculated from the specified Length and Offset. This is useful when each the user wishes to set the LR channel beginning date to correspond to a known date, such as an inportant pivot point on the chart.
AlertBand, if non-zero, is the band number that will trigger an alert when price crosses it. This is useful to signal breakouts from the channel.
AlertBandColor is the color of the outer band when the OuterBandAlert is set to true. This reminds the user that the indicator has been set to trigger alerts.
CalcSeconds is the interval (in seconds) that the indicator will test for any movement of the LR channel centerline by the user.
The remainder of the parameters are self-explanatory.

Downloads
Initial posted version: 09/06/09
Latest Update: 10/13/21
*.ELD files are compiled for TS 9.5
All Code and *ELD files packaged here:
LRChanArray.zip (updated version, improved)
The improved version uses arrays to avoid the annoyance of inappropriate MaxBarsBack settings
preventing the indicator from displaying, and needing to be adjusted according to the length of the trend line.
It also uses Trendline drawing objects, and no longer uses TL_ commands.
Users of earlier versions of Tradestation may compile the code
from the text files included in the above *.zip file.
The code may be visualized here:
Indicator LRChanARray (updated version, improved)