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.
– 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
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
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.
Available colors
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 |
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.