# Program 63 | Linear regression plot and oscillator

## Linear regression plots and an oscillator based on plots

Click on any of the following images to see bigger versions.

In tutorial 49 I demonstrated how to create a linear regression channel consisting of a linear regression line together with two parallel lines a user defined number of standard deviations away. This program uses a similar technique to draw the channel and plot three lines that are located at the right ends of a smoothed version of the channel. A second option allows oscillators to be draw based on two of the plots. This is all explained in greater detail below. The linear regression formulae are explained in tutorial 48.

The following image shows the plots (including a non-smoothed version of the center line) and demonstrates how the plot is related to the linear regression channel. Notice how the end of each successive linear regression coincides with the plot:

The arrows shows the plot being drawn at the end of the linear regression lines. N.B the upper and lower plots (and one of the middle plot displayed as a yellow color) are based on smoothed version of this plot.

One of the user inputs allows the linear regression channel end points to be plotted as follows:

The first and second upper lines and the first and second lower lines are drawn a user input number of standard deviations above and below of the smoothed center line. The upper and lower lines are smoothed. One of the middle lines is smoothed and the other is not.

The second option draws two oscillators. One is based on the first upper line and one is based on the first lower line. These lines are calculated using the unsmoothed version of the end value of the center linear regression line.

Unlike the program included with tutorial 49, this program will run on second, tick and other charts, such as Renko charts. See examples of these charts lower down the page.

Program 63 was developed for TradeStation 9.5 and above and is not compatible with MultiCharts.

An UNPROTECTED version (i.e. the TradeStation EasyLanguage indicator is fully functional and you can see the source code) is also available for for immediate download for \$49.95- by clicking the ‘add to cart’ button. Because this version is  unprotected you can open it, see the program code and modify it.

If you are a Gold Pass member make sure you enter the special coupon code to get 20% discount off these prices.

### Input values

int NumBars( 20 ), // The number of bars to consider when calculating the linear regression
double Price( C ), // The price to consider when calculating the linear regression
double NumDevsUp1( 2 ), // The number of standard deviations of the end of the linear regression to draw upper channel above linear regression line
double NumDevsDn1( -2 ), // The number of standard deviations of the end of the linear regression to draw lower channel below linear regression line
double NumDevsUp2( 2.5 ), // The number of standard deviations of the end of the linear regression to draw upper channel above linear regression line
double NumDevsDn2( -2.5 ), // The number of standard deviations of the end of the linear regression to draw lower channel below linear regression line
int GraphOption( 3 ), // See different presentation options explained below

int SmoothLength( 5 ), // The smoothed length used to triple smooth of linear regression values
int OscLookBack( 10 ), // The number of bars over which to find the highest and lowest values when calculating the oscillator
bool Oscillator( False ), // Set to false for the normal plot, set to true for the oscillator

// Trendline attributes
int TLWeightMid( 3 ), // Determines the thickness oof the trendline. Valid numbers are integers between 0 and 6
int TLWeightUpLo( 2 ), // Determines the thickness oof the trendline. Valid numbers are integers between 0 and 6
int TLStyle( 0 ), // 0 = solid, 1 = dashed, 2 = dotted, 3 = dashed2, 4 = dashed3
int TLTransparency( 255 ), // Sets the alpha component (transparency) of this color structure, where 0 is fully transparent and 255 is fully opaque
string UpperColor( “Red” ), // Color of lines indicating possible bullish divergence
string MidColor( “Yellow” ), // Color of lines indicating possible bullish divergence
string LowerColor( “Green” ); // Color of lines indicating possible bullish divergence

### Available Colors

The user inputs: UpperColor, MidColor, and LowerColor may be populated with any of the following values. N.B. They must be enclosed within quotes.

 AliceBlue DarkSlateGray LightSalmon PaleVioletRed AntiqueWhite DarkTurquoise LightSeaGreen PapayaWhip Aqua DarkViolet LightSkyBlue PeachPuff Aquamarine DeepPink LightSlateGray Peru Azure DeepSkyBlue LightSteelBlue Pink Beige DimGray LightYellow Plum Bisque DodgerBlue Lime PowderBlue Black Firebrick LimeGreen Purple BlanchedAlmond FloralWhite Linen Red Blue ForestGreen Magenta RosyBrown BlueViolet Fuschia Maroon RoyalBlue Brown Gainsboro MediumAquamarine SaddleBrown Burlywood GhostWhite MediumBlue Salmon CadetBlue Gold MediumOrchid SandyBrown Chartreuse Goldenrod MediumPurple SeaGreen Chocolate Gray MediumSeaGreen Seashell Coral Green MediumSlateBlue Sienna CornflowerBlue GreenYellow MediumSpringGreen Silver Cornsilk Honeydew MediumTurquoise SkyBlue Cyan HotPink MediumVioletRed SlateBlue DarkBlue IndianRed MidnightBlue SlateGray DarkBrown Indigo MintCream Snow DarkCyan Ivory MistyRose SpringGreen DarkGoldenrod Khaki Moccasin SteelBlue DarkGray Lavender NavajoWhite Tan DarkGreen LavenderBlush Navy Teal DarkKhaki LawnGreen OldLace Thistle Dark Magenta LemonChiffon Olive Tomato DarkOliveGreen LightBlue OliveDrab Turquoise DarkOrange LightCoral Orange Violet DarkOrchid LightCyan OrangeRed Wheat DarkRed LightGoldenrodYellow Orchid White DarkSalmon LightGray PaleGoldenrod WhiteSmoke DarkSeaGreen LightGreen PaleGreen Yellow DarkSlateBlue LightPink PaleTurquoise YellowGreen

Program 63 was developed for TradeStation 9.5 and above and is not compatible with MultiCharts.

An UNPROTECTED version (i.e. the TradeStation EasyLanguage indicator is fully functional and you can see the source code) is also available for for immediate download for \$49.95- by clicking the ‘add to cart’ button. Because this version is  unprotected you can open it, see the program code and modify it.

If you are a Gold Pass member make sure you enter the special coupon code to get 20% discount off these prices.

Please join our email mailing list if you have not already done so and we will let you know when we release new tutorials or programs.

### Program 63 was developed for TradeStation 9.5 and above and is not compatible with MultiCharts.

An UNPROTECTED version (i.e. the TradeStation EasyLanguage indicator is fully functional and you can see the source code) is also available for for immediate download for \$49.95- by clicking the ‘add to cart’ button. Because this version is  unprotected you can open it, see the program code and modify it.

If you are a Gold Pass member make sure you enter the special coupon code to get 20% discount off these prices.

If you are a Gold Pass member make sure you enter the special coupon code to get 20% discount off these prices.

### Graph options

1. In the first option the channel is always moved to the end of the chart to apply to the last NumBars bars.

2. A new channel is drawn every time a new bar is printed.

3. The channel is drawn when the show me study is first applied to the chart and doesn’t move.

### Different chart types

Please note that any screen shots on this site are examples and are not meant to imply that any of these programs will generate profitable trades.

THESE INDICATORS, SHOW ME STUDIES, STRATEGIES AND OTHER PROGRAMS HAVE BEEN INCLUDED SOLELY FOR EDUCATIONAL PURPOSES.

TO THE BEST OF MARKPLEX CORPORATION’S KNOWLEDGE, ALL OF THE INFORMATION ON THIS PAGE IS CORRECT, AND IT IS PROVIDED IN THE HOPE THAT IT WILL BE USEFUL. HOWEVER, MARKPLEX CORPORATION ASSUMES NO LIABILITY FOR ANY DAMAGES, DIRECT OR OTHERWISE, RESULTING FROM THE USE OF THIS INFORMATION AND/OR PROGRAM(S) DESCRIBED, AND NO WARRANTY IS MADE REGARDING ITS ACCURACY OR COMPLETENESS. USE OF THIS INFORMATION AND/OR PROGRAMS DESCRIBED IS AT YOUR OWN RISK.

ANY EASYLANGUAGE OR POWERLANGUAGE TRADING STRATEGIES, SIGNALS, STUDIES, INDICATORS, SHOWME STUDIES, PAINTBAR STUDIES, PROBABILITYMAP STUDIES, ACTIVITYBAR STUDIES, FUNCTIONS (AND PARTS THEREOF) AND ASSOCIATED TECHNIQUES REFERRED TO, INCLUDED IN OR ATTACHED TO THIS TUTORIAL OR PROGRAM DESCRIPTION ARE EXAMPLES ONLY, AND HAVE BEEN INCLUDED SOLELY FOR EDUCATIONAL PURPOSES. MARKPLEX CORPORATION. DOES NOT RECOMMEND THAT YOU USE ANY SUCH TRADING STRATEGIES, SIGNALS, STUDIES, INDICATORS, SHOWME STUDIES, PAINTBAR STUDIES, PROBABILITYMAP STUDIES, ACTIVITYBAR STUDIES, FUNCTIONS (OR ANY PARTS THEREOF) OR TECHNIQUES. THE USE OF ANY SUCH TRADING STRATEGIES, SIGNALS, STUDIES, INDICATORS, SHOWME STUDIES, PAINTBAR STUDIES, PROBABILITYMAP STUDIES, ACTIVITYBAR STUDIES, FUNCTIONS AND TECHNIQUES DOES NOT GUARANTEE THAT YOU WILL MAKE PROFITS, INCREASE PROFITS, OR MINIMIZE LOSSES.