EasyLanguage Object Reference
About Drawing Object Classes
The EasyLanguage drawing object classes allow you to create drawing objects on a chart from your analysis technique and to programmatically manage their appearance and position. The trendline and text objects parallel the functionality of the legacy EasyLanguage TL_xxx and Text_xxx reserved words. The Ellipse, HorizontalLine, Rectangle, and Vertical line objects are equivalent to the drawing tools you were able to manually insert in a chart.
Drawing Object Classes
- Ellipse - Draws an ellipse based on two points, the starting point at the upper left and the ending point at the lower right of a bounding rectangular area. The border line and fill pattern characteristics can be user specified.
- HorizontalLine - Draws a horizontal line that intersects a specified price. The line style and thickness can be user specified.
- Rectangle - Draws a rectangle based on two points, the starting point at the upper left and the ending point at the lower right corner of the rectangle. The border line and fill pattern characteristics can be user specified.
- Text - Displays a text string at a specified point. The font style and horizontal/vertical centering can be user specified.
- TrendLine - Draws a trendline between two points, the starting point and the ending point. The line characteristics and left/right extension properties can be user specified.
- VerticalLine -
Draws a vertical line that intersects a specified time interval. The line style and thickness can be user specified.
- Used to define a drawing object point based on a bar number and a price value. Objects positioned with a BNPoint will move along with the bars they are anchored to.
- DTPoint - Used to define a drawing object point based on a bar date/time stamp and a price value. Objects positioned with a DTPoint will move along with the bars they are anchored to.
- XYPoint - Used to define a drawing object (Ellipse, Rectangle, or Text) point based on a chart X and Y location (relative to the upper left corner of the chart window). Objects positioned with an XYPoint will not move when the bars are scrolled.
To use EasyLanguage drawing objects,
you should have the following elements:
- Declare a variable for each type of object to be
used. The class type of each variable must be appropriate
for the object it will reference. Remember to include the namespace identifier "elsystem.drawingtools" in front of
the specific class type unless you have previously added a
for the namespace. In this example, "myHorizLine1"
and "myTrendLine1" are the names of the variables being
created for each drawing object type.
vars: HorizontalLine myHorizLine1(null), // declare myHorizLine1 as a HorizontalLine type
TrendLine myTrendLine1(null), // declare myTrendLine1 as a TrendLine type
BNPoint BNPoint1(null), BNPoint BNPoint2(null); // declare bar number points 1 & 2
- Create an instance of each drawing object
at the point locations specified.
myHorizLine1 = HorizontalLine.Create(last-.02); // create a horizontal line at .02 below the last price
myPoint1 = BNPoint.Create(barnumber-10,close); // create first trendline point 10 bars to the left of the current bar
myPoint2 = BNPoint.Create(barnumber,close); // create second trendline point at current bar
myTrendLine1 = TrendLine.Create(myPoint1,myPoint2 ); // create a trend line and assign it to myTrendLine
(Note that you can also create the above trendline without needing to define BNPoint objects by directly specifying the BNPoint values when creating the trendline instance)
myTrendLine1 = TrendLine.Create(BNPoint.Create(barnumber-10,close),BNPoint.Create(barnumber,close));
- Add drawing objects (e.g. TrendLine, HorizontalLine) to a the DrawingObjects property of the AnalysisTechnique
- Associate an event handler with the objects (to call the DOClick method when either drawing object is clicked).
myHorizLine1.Click += DOClick;
myTrendLine1.Click += DOClick;
- Finally, write the method(s) to be called when a drawing object click event
method void DOClick( Object sender,DrawingObjectEventArgs args)
// Your EasyLanguage code to handle a drawing object that has been clicked
You can set alerts for TrendLine, HorizontalLine, and VerticalLine drawing objects so that they will notify you when specified alert criteria occur.
Refer to Using Alert with Drawing Objects for more information and examples.