Skip to content

Tutorial 186 | Inside and outside bar high and low lines

T186InsideInsideBar2

Tutorial 186 looks at three different approaches to analyzing a chart to find inside and outside bars and then drawing or plotting lines at their highs and lows until breached by price. The three approaches are:

  1. An indicator that plots the levels (_Tutorial186)
  2. A function (_Tutorial186fn) that does the same analysis as the indicator (_Tutorial186)  and then draws the lines using the legacy drawing tools
  3. A function (_Tutorial186fnOJ) that does the same analysis as the indicator (_Tutorial186) and then draws the lines using drawing object

The programs have been tested with minute charts in TradeStation version 10. They could, potentially, be used with other price series inputs but have not been tested with anything other than high and low prices.

Inside and outside bars

An ‘inside bar’ is a two-bar pattern in which the inside bar is smaller and within the high to low range of the previous bar, i.e. the high is lower than the previous bar’s high, and the low is higher than the previous bar’s low. An ‘outside bar’ where the bar needs to have a higher high and a lower low than the previous candlestick. When the current bar has a higher high and a low low it is completely ‘outside’ the previous candlestick. 

1. The tutorial 186 indicator version

Tutorial 186 indicator checks for inside bars and outside bars and then plots the high and the low of the pattern until either line is breached by price. The other line continues to be plotted (i.e if the price goes below the low line, it is stopped but the high line continues to be drawn.)

SETUP INFORMATION

To setup the program ensure the following:

  • The plot style is set to point for Plot1 and Plot5
  • The plot style is set to line for Plot3, Plot4, Plot7 and Plot8
  • Display update indication, display plot value in data line data tip and data window, and don’t automatically connect plot lines are all selected for Plot3, Plot4, Plot7, and Plot8
  • Select preferred colors for all the plots
  • Set scaling as same access as underlying data

Technical lessons

Tutorial 186 provides information about using the Plot and NoPlot statements plus the various options that are available within the plot statement (including the format of the plot, color etc). The program could also have been written using the drawing tools, however the plot statement makes it a far simpler process.

User inputs

Link
Tutorial 186 inputs
Tutorial 186 inputs
Link
Tutorial 186 with the outside bar user input set to true.
Tutorial 186 with the outside bar user input set to true.
Link
Showing both the inside bar and outside bar lines
Showing both the inside bar and outside bar lines

2. Function that draws lines using the legacy drawing tools

In the second program the analysis is done in a function. Rather than plotting the lines (plots are not allowed in functions) the lines are drawn using the legacy drawing tools. The following is a short excerpt from the function:

// Draw a line showing the inside/outside  bar high if it has not been crossed (i.e. StopIS_OSH is false)
Value2 = TL_New( D[1], T[1], IS_OSCurrHi, D, T, IS_OSCurrHi ); 
TL_SetColor( Value2, Green ); // Set color
TL_SetSize( Value2, 6 ); // Set thickness

The function can be called from another program using the following syntax:

VALUE1 = _Tutorial186fn( H, L, true ); // Call the function that draws lines using legacy drawing tools

The last input determines whether the function highlights inside or outside bars. If it is set to TRUE it looks for inside bars. If it is set to FALSE it looks for outside bars.

Link
An example of when the function that draws lines using the legacy drawing tools is called by an indicator that applied to the chart
An example of when the function that draws lines using the legacy drawing tools is called by an indicator that applied to the chart

Video explaining tutorial 186 function that uses legacy drawing tools

3. Function that draws lines using the trendline drawing object

In this third program the analysis is done in a function. Rather than plotting the lines (plots are not allowed in functions) the lines are drawn using the drawing object. . The following is a short excerpt from the function:

/TLObj = TrendLine.create( DTPoint.Create( DateTime.FromELDateAndTime( _date1, _Time1 ), Price1 ),
DTPoint.Create( DateTime.FromELDateAndTime( _Date2, _Time2 ), Price2 ) );// Create an instance of a trendline object based on two points
TLObj.Persist = True; // Trendline remains on screen after tick refreshes
TLObj.Style = 1; // Trendline will be drawn as a solid line
TLObj.Weight = 6;
TlObj.Color = Color.FromName( Colour );
TLObj.ExtRight = FALSE;
DrawingObjects.Add( TLObj );

This functionality is included in a method that is called each time a new line needs to be drawn.

The function can be called from another program using the following syntax:

Value1 = _Tutorial186fnOJ( H, L, True ); // Call the function that draws lines using drawing objects

The last input determines whether the function highlights inside or outside bars. If it is set to TRUE it looks for inside bars. If it is set to FALSE it looks for outside bars.

Link
Lines drawn using the trendline drawing object using the second function
Lines drawn using the trendline drawing object using the second function
This GIF shows what happens when an inside bar begins to form within another inside bar and then price invalidates the second inside bar. (The speed of the video was increased.)
This GIF shows what happens when an inside bar begins to form within another inside bar and then price invalidates the second inside bar. (The speed of the video was increased.)
Hopefully you can understand this tutorial and replicate it for your own use and education. If you want to save some time typing in the code then the Tutorial 186 indicators and functions are available for  IMMEDIATE download for $29.95  by clicking the following ‘add to cart’ button. 

The following unprotected programs are included:

  • _Tutorial186 (an indicator)
  • _t186FNTEST (an indicator)
  • _Tutorial186fn (a function)
  • _Tutorial186fnOJ (a function)

The tutorial indicator program is compatible with MultiCharts as is the function that uses legacy drawing tools. The other function is not compatible.

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.