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
'using' statement
for the namespace. In this example, "myHorizLine1"
and "myTrendLine1" are the names of the variables being
created for each drawing object type.
using elsystem.drawingobjects;
using elsystem;
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[10]);// 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[10]),BNPoint.Create(barnumber,close));
- Add drawing objects (e.g. TrendLine, HorizontalLine) to a the DrawingObjects property of the AnalysisTechnique
DrawingObjects.Add(myHorizLine1);
DrawingObjects.Add(myTrendLine1);
- 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
happens.
method void DOClick( Object sender,DrawingObjectEventArgs args)
begin
// Your EasyLanguage code to handle a drawing object that has been clicked
end;