EasyLanguage Object Reference

Trendline Class

Draws a trendline on a chart through two points. The points may be time-based (DTPoint) or bar number-based (BNPoint). Appearance may altered and an alert enabled using appropriate properties. Trendlines are often used to track market direction and identify breakouts. To use this in an analysis technique, be sure that it is setup as described in About Drawing Objects.

A trendline may be created and drawn from the Close of 20 bars ago to the Close of the last bar on the chart as follows:

using      elsystem.drawingobjects;
vars:      TrendLine myTrendLine1(null), BNPoint myBNPoint1(null), BNPoint myBNPoint2(null);

If LastBarOnChart then once begin
myBNPoint1 = BNPoint.Create(barnumber-20,close[20]); // create a starting point 20 bars to the left myBNPoint2 = BNPoint.Create(barnumber,close); // create an ending point at current bar myTrendLine1 = TrendLine.create(myBNPoint1,myBNPoint2); // create an instance of a trendline object based on two bar number points myTrendLine1.Persist = True; // trendline remains on screen after tick refreshes myTrendLine1.Style = 2; // trendline will be drawn as a dotted line DrawingObjects.Add(myTrendLine1); // plot the trendline on the chart end;

Note that the Persist property in the above example, as well as additional properties, methods, and events not listed below, are inherited from DrawingObject.

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-20,close[20]),BNPoint.Create(barnumber,close));

Namespace: elsystem.drawingobjects

[ Expand All ]
Properties

   Additional properties, methods, and events are described in the classes listed under Inheritance Hierarchy (see below).

  Name Type Description
Public property Alert object References additional properties used to enable and configure alert criteria for the trendline. See PriceAlert and Using Alerts for more information.
Public property EndPoint object Gets the ending point of the trendline as a DOPoint object.
Public property ExtLeft bool Gets or sets the extend left property. True to extend the trendline to the left.
Public property ExtRight bool Gets or sets the extend right property. True to extend the trendline to the right.
Public property StartPoint object Gets the starting point of the trendline as a DOPoint object.
Public property Style enum Gets or sets the TrendLine style using a StyleType enumerator.
Public property Weight enum Gets or sets the line weight from an enumerated list. See Weight for a list of values.
Methods
  Name Description
Public property Create(DTPoint, DTPoint) Initializes a new instance of the Trendline class. The first parameter is a DTPoint object representing the start point of the line; the second parameter is a DTPoint object representing the end point of the line.
Public property Create(DTPoint, DTPoint, int) Initializes a new instance of the Trendline class. The first parameter is a DTPoint object representing the start point of the line; the second parameter is a DTPoint object  representing the end point of the line, and the third parameter is an integer representing the data number (data1 - 50).
Public property Create(BNPoint, BNPoint) Initializes a new instance of the Trendline class. The first parameter is a BNPoint object representing the start point of the line; the second parameter is a BNPoint object representing the end point of the line.
Public property Create(BNPoint, BNPoint, int) Initializes a new instance of the Trendline class. The first parameter is a BNPoint representing the start point of the line; the second parameter is a BNPoint object representing the end point of the line, and the third parameter is an integer representing the data number (data1 - 50).
Public property GetValue(DateTime) Returns the price for a specified DateTime object.
Public property GetValue(int) Returns the price for a specified bar number integer.
Public property SetEndPoint(DTPoint) Sets the TrendLine end point using a DTPoint object.
Public property SetEndPoint(BNPoint) Sets the TrendLine end point using a BNPoint object.
Public property SetStartPoint(DTPoint) Sets the TrendLine start point using a DTPoint object.
Public property SetStartPoint(BNPoint) Sets the TrendLine start point using a BNPoint object.
Inheritance Hierarchy

elsystem.Object

  elsystem.DrawingObject

    elsystem.DrawingObjects.TrendLine