Skip to content

Tutorial 49-2 | Linear regression using just today’s bars

This new version of tutorial 49 (_Tutorial49-use bars in day) is very similar to the program in tutorial 49, except in this case the linear regression is calculated and drawn solely for the bars that have formed for the current day (or the most recent day).

_Tutorial49-use bars in day works with TradeStation (8.7 forward) and MultiCharts.

This tutorial uses the code originally written for tutorial 48 and tutorial 49 that creates a line using linear regression that best fits chart data. The linear regression technique uses the least squares method to calculate the slope and y-intercept of this line.

As in Tutorial 49, the standard deviation of the right most end of the regression line is calculated in order to create a channel made up of two parallel lines above and below the linear regression line. These lines are drawn a user input multiple of standard deviations above and below the original linear regression line.

Since this new tutorial program is ONLY using today’s bars the distance of the parallel lines differs from those in the standard program which also uses the value of the right most end of the regression line from the previous day(s) depending on the NumBars setting. In this new program the NumBars input does not exist.  Rather NumBars has been re-purposed as a variable and incremented each bar after the start of the day.

The new program also replaces a nested If…then, structure with Switch… Case syntax when applying the display options (see below).

Click here to download a copy of the program created in this tutorial together with the new bonus program for $29.95:

The tutorial includes three different options for displaying the channel:

Option 1 (left)

In the first option the channel is drawn from the start of the day to the last bar. It is updated for each new bar.

Option 2 (middle)

A new channel is drawn every time a new bar is printed from the first bar of the day to the current bar.

Option 3 (right)

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

Click here to download a copy of the program created in this tutorial together with the new bonus program for $29.95:
You might also be interested in program 63. Program 63 draws linear regression lines, and then creates a smoothed plot based on the linear regression end point. It also offers the option to plot oscillators based on non-smoothed plots.

Tutorial 49-2 | Linear regression using just today’s bars video

This video demonstrates how the tutorial 49 program was modified to just use today’s bars.

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.

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.

If you see any errors in this tutorial – or we have not made something clear, we would be most grateful if you could please let us know. E-mail us at: tutorials@markplex.com. Also, let us know if you have any ideas for new tutorials.

EasyLanguage is a programming language that is part of the TradeStation trading platform. It can be used to write programs to help in the technical analysis and trading of foreign exchange (forex or FX), commodities (e.g. the Dow e-mini, S&P e-mini etc), options, and stocks.