Program 75 | Raff linear regression channel

Raff linear regression channel

Program 75 is a TradeStation EasyLanguage indicator that plots and/or draws a Raff linear regression channel on a chart

An animated GIF showing a 10 bar channel being applied to a chart in several places

Many linear regression channels base the height of the channel on a calculation of standard deviations. A Raff linear regression channel bases the height of the channel on the price that is furthest away from the linear regression line in the channel. This is illustrated in the following image.

In this example showing a channel of 20 bars, the program determines that the distance from the linear regression line and the high of the 6th bar is the greatest distance for all the bars in the channel

In the above image (measuring the distance between the line and the highs and the line and the lows). The high of the 6th bar from the start of the channel is the greatest distance for all the bars in the channel. The upper and lower lines of the channel are moved to be this distance from the center line parallel to the linear regression line. The additional lines drawn between the extremes and drawn a 61.8% of the distance, representation a Fibonacci level.

Program 75 applied to a 15 minute @ES chart. Notice how the lower Fibonnacci level appears to provide support.

In addition to the way the program uses the Raff technique to determine how high the channel is (rather than a multiple of standard deviation), it also allows the user to create a channel that ends at a specific bar, by clicking on that bar. The program detects the bar click and redraws the channel.

Program 75 applied to a daily AMZN chart. The TLExtRight user input is set to TRUE.

A further innovation is to also create the channels using the plot statement. This creates a record of where previous channels were drawn, as in the following image. Whether lines are drawn or plotted is controlled by user inputs: Plots and DrawLines. When the chart is refreshed, inputs modified or turned off and on, the plots and lines disappear.

Video demonstration of program 75 Part 1 | introduction and using on a chart

Video demonstration of program 75 Part 2 | maxbarsback settings

Program setup

Make sure that in the indicator options for each plot, the “Don’t automatically connect plot lines” option is checked. If not the chart will appear something like the following:

The following screen shows the styling options for plots:

Maxbarsback options

In the general tab for format indicator you have two options:

  1. Use auto-detect
  2. Specify a number using the user defined option

Maxbarsback settings

If you specify the value you will generate an error if you click a bar which is greater than this number of bars from the end of the chart. If you select auto-detect, the chart will reload every time that you click a bar earlier than a bar you have already clicked. The technical reason for this behavior is discussed below.

Inputs

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 UPrice( H ), // The price used to determine the biggest ‘distance’ above the linear regression line for bars above the linear regression line
double LPrice( L ), // The price used to determine the biggest ‘distance’ below the linear regression line for bars below the linear regression line
bool Plots( TRUE ), // Plot the linear regression channel
bool DrawLines( TRUE ), // Use drawing tools to draw the linear regression channel

// Trendline drawing objects attributes
int TLWeight( 3 ), // Determines the thickness of 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
bool TLExtRight( FALSE ), // Extend the TL lines drawn to the right
string TopColor( “Red” ), // The color of the top regression channel line or plot
string FibUColor( “DarkRed” ), // The color of the top Fibonnacci regression channel line or plot
string MidColor( “Yellow” ), // The color of the middle regression channel line or plot
string FibLColor( “DarkGreen” ), // The color of the lower Fibonacci regression channel line or plot
string LowColor( “Green” ); // The color of the lower regression channel line or plot

Color options

AliceBlueDarkSlateGrayLightSalmonPaleVioletRed
AntiqueWhiteDarkTurquoiseLightSeaGreenPapayaWhip
AquaDarkVioletLightSkyBluePeachPuff
AquamarineDeepPinkLightSlateGrayPeru
AzureDeepSkyBlueLightSteelBluePink
BeigeDimGrayLightYellowPlum
BisqueDodgerBlueLimePowderBlue
BlackFirebrickLimeGreenPurple
BlanchedAlmondFloralWhiteLinenRed
BlueForestGreenMagentaRosyBrown
BlueVioletFuschiaMaroonRoyalBlue
BrownGainsboroMediumAquamarineSaddleBrown
BurlywoodGhostWhiteMediumBlueSalmon
CadetBlueGoldMediumOrchidSandyBrown
ChartreuseGoldenrodMediumPurpleSeaGreen
ChocolateGrayMediumSeaGreenSeashell
CoralGreenMediumSlateBlueSienna
CornflowerBlueGreenYellowMediumSpringGreenSilver
CornsilkHoneydewMediumTurquoiseSkyBlue
CyanHotPinkMediumVioletRedSlateBlue
DarkBlueIndianRedMidnightBlueSlateGray
DarkBrownIndigoMintCreamSnow
DarkCyanIvoryMistyRoseSpringGreen
DarkGoldenrodKhakiMoccasinSteelBlue
DarkGrayLavenderNavajoWhiteTan
DarkGreenLavenderBlushNavyTeal
DarkKhakiLawnGreenOldLaceThistle
Dark MagentaLemonChiffonOliveTomato
DarkOliveGreenLightBlueOliveDrabTurquoise
DarkOrangeLightCoralOrangeViolet
DarkOrchidLightCyanOrangeRedWheat
DarkRedLightGoldenrodYellowOrchidWhite
DarkSalmonLightGrayPaleGoldenrodWhiteSmoke
DarkSeaGreenLightGreenPaleGreenYellow
DarkSlateBlueLightPinkPaleTurquoiseYellowGreen

Technical lessons

Program 75 uses the following programming techniques and syntax:

  • The Chartinghost object to detect when a bar is clicked and to provide information on that bar
  • Drawing objects (BNPoint and Trendline) are used to draw the channel lines
  • The plot command to plot the channel lines
  • Using strings to designate both plot and trendline colors
  • The linear regression calculation

Drawing objects

To draw lines with the TradeStation drawing objects we create a pair of BNPoint objects using a bar number and price. The trend line is created and styled and then added to the chart.

Two potential ‘gotchas’
Gotcha 1

A BNPoint refers to the absolute bar index (zero-based) of the collection of bars in a chart. This is not the same as the BarNumber function or CurrentBar reserved word which count the number of bars available for analysis after MaxBarsBack. So to create a BNPoint for the current bar (BarNumber) would be:

NewBar = BarNumber + MaxBarsBack – 1;

Gotcha 2

Another issue that can cause what appear to be spurious results are the ‘Show empty daily trading periods for traditional chart types’ and ‘Show empty intraday session periods for traditional chart types’ settings. These can be found by clicking View – Chart Analysis Preferences

tutorial103-chart-analysis-prefs

If these are selected, the chart includes blank bars which ‘confuse’ the bar number for BNPoints. The ‘Show empty daily trading periods for traditional chart types’ and ‘Show empty intraday session trading periods for traditional chart types’ must be deselected.

Program download

Program 75 was developed for TradeStation 9.5 and above and is not compatible with MultiCharts because of the objects used.

An UNPROTECTED version (i.e. the TradeStation EasyLanguage is fully functional and you can see the source code) and associated unprotected function is available for for IMMEDIATE download for $29- by clicking the ‘add to cart’ button. After download the program can be opened, you will be able to see the program code and modify it.

After purchase you will be redirected to a download page, so don’t close the browser. You will also receive an automated email with the download link and instructions for accessing the bonuses.

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

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

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.

Disclaimer The information, materials, products and services on this Web site are made available subject to the following terms and conditions. Markplex Corporation reserves the right to change these terms and conditions at its sole discretion. This Web site and any downloads, videos, tutorials, programs and information contained herein is presented solely for educational, informational, and/or entertainment use and under no circumstances should be used for actual trading. We at Markplex Corporation are not Broker/Dealers, Financial Advisers or Registered Analysts. No offer or solicitation to buy or sell securities, securities derivatives, futures products or off-exchange foreign currency (forex) transactions of any kind, or any type of trading or investment advice, recommendation or strategy, is made, given or in any manner endorsed by Markplex Corporation. You are fully responsible for any investment or trading decisions you make. Futures and options trading has a large potential risk. You must be aware of the risks and be willing to accept them in order to invest in the futures and options markets. This Web site is neither a solicitation nor an offer to buy and/or sell futures or options. No representation is being made that any account will or is likely to achieve profits or losses similar to those discussed on this Web site. Past performance, whether actual or indicated by historical tests of strategies, is no guarantee of future performance or success. No warranties of profitability are being made or given. There is a possibility that you may sustain a loss equal to or greater than your entire investment regardless of which asset class you trade (equities, options futures or forex); therefore, you should not invest or risk money that you cannot afford to lose. CFTC RULE 4.41 - Hypothetical or simulated performance results have certain inherent limitations. Unlike an actual performance record, simulated results do not represent actual trading. Also, since the trades have not actually been executed, the results may have under- or over-compensated for the impact, if any, of certain market factors, such as lack of liquidity. Simulated trading programs in general are also subject to the fact that they are designed with the benefit of hindsight. No representation is being made that any account will or is likely to achieve profits or losses similar to those shown. Screen shots on this site are examples and are not meant to imply that any of the programs or tutorials available on this Web site will generate profitable trades. 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, informational, and entertainment use. 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. 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 Web site including the information, tutorials and/or programs included on it is at your own risk. You shall indemnify and hold Markplex Corporation harmless from any and all liability, loss, trading losses, costs, damage, or expense, including attorneys' fees you or third party may suffer (other than damage to your tangible property or injuries to employees occurring during the course of work) as a result of claims, demands, costs, or judgments arising out of third party and any other claims based on Markplex Corporation's performance, including, but not limited to losses resulting from the use of Markplex Corporation developed software, programs, web sites, tutorials, or the TradeStation charting and/or trading platform. Any testimonials on this Web site may not be representative of the experience of other clients and are not indicative of future results or success.
This Web site contains or may contain references and links to other companies and/or their Web sites, none of which is under the control of Markplex Corporation. Markplex Corporation makes no representations, warranties or endorsements whatsoever about any other Web sites to which you may have access through the Markplex Corporation Web site, or any products or services of those other companies, even if the products or services of those other companies or their Web sites are described or offered on the Markplex Corporation Web site or integrated with Markplex Corporation's products or services. TradeStation®, EasyLanguage® and PowerEditor® are registered trademarks of TradeStation Technologies, Inc. Other brand and product names which appear on this site are the trademarks or service marks of their respective owners, including: Microsoft® is a registered trademark in the United States Microsoft®Excel® is a registered trademark of Microsoft® Neither TradeStation Technologies nor any of its affiliates has reviewed, certified, endorsed, approved, disapproved or recommended, and neither does or will review, certify, endorse, approve, disapprove or recommend, any product or service that offers training, education or consulting regarding the use of EasyLanguage.

By continuing to use and navigate our sites, services, applications, tools or messaging, you are agreeing to our Terms and Conditions and the use of cookies, web beacons and similar technologies as described in our Privacy Policy and Privacy Policy on the use of cookies.