Skip to content

Tutorial 180 | Text Objects Basics

T180-1

TradeStation EasyLanguage Tutorial 180 demonstrates how to draw a line, a rectangle and a text label by specifying a start date, time and price and an end date, time and price. The times can be specified to the second. The tutorial uses Parse method of the DateTime class to convert user input strings (in mm/dd/yyyy hh:mm:ss format) into DateTime objects. These values are combined with user input prices to create DTPoint objects using DTPoint.Create. These DTpoints are then used to create a trendline, a rectangle and a text label.

// Example of the string format for the date/time input:
String LineEnd( "6/10/2022 11:15:32" ), // In mm/dd/yyyy hh:mm:ss format
 

Additional functionality is included so that the rectangle is drawn even if the end date time is not currently visible on the chart. This is achieved by checking the current BarDateTime at the beginning of each bar. If it is less than the LineEndTime then the rectangle has its end time set to the most right display datetime. This is repeated as each new bar is added to the chart, until the bar DateTime is equal to or greater than the end time.

Technical lessons covered in this tutorial include:
– Drawing lines, rectangles and text objects
– Using DateTime.Parse to convert a string to a DateTime object
– Using methods to create and update drawing objects
– Using ‘Composite Formatting’ to print data
– Ensuring a rectangle is visible even if the end datetime is not currently on the chart
This tutorial does not work with MultiCharts.

To create a line or a rectangle that extends across all the visible chart, enter a LineStart value for a bar on the chart that is before the current window and LineEnd for a date and time after the last visible time on the chart.

Inputs

The LineColor input is used to color the trendline, rectangle and text objects.  TLTransparency determines the transparency of the filling of the rectangle. TLWeight determines the thickness of the trendline. Valid numbers are integers between 0 and 6. TLStyle determines the style of the trendline. Possible values are: 0 = solid, 1 = dashed, 2 = dotted, 3 = dashed2, 4 = dashed3

Link
Inputs for tutorial 180
Inputs for tutorial 180

Free Gold Pass download

If you are a Gold Pass member you can download the tutorial 180 program below for free. (Make sure that you are logged into Gold Pass): This content is for members only.
Link
When a new bar is formed and the rectangle is complete, the trendline is drawn
When a new bar is formed and the rectangle is complete, the trendline is drawn

Video showing the development of the tutorial 180 program | Part 1

Video explaining the development of the tutorial 180 program | Part 2

Correction

In the videos, line 128 is shown of the tutorial program as:

Rect1.FillColor = Color.FromArgb( 100, Color.FromName( LineColor ) ) ; // Fill color

This is incorrect as it means that the transparency of the rectangle is ‘hardcoded’ to 100.
The corrected statement is:

 
Rect1.FillColor = Color.FromArgb( TLTransparency, Color.FromName( LineColor ) ) ; // Fill color

Which means that the transparency will vary depending on the value of the user input: TLTransparency.

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 180 program is available for  IMMEDIATE download for $19.95  by clicking the following ‘add to cart’ button. Gold Pass members can download it for free (see above).

Available colors

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

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.