EasyLanguage Object Reference

Rectangle Class

Draws a rectangle of a specified size on a chart at a specified location. Appearance may altered using appropriate properties. A rectangle is a non-analytical drawing tool used to highlight specific portions of a chart.

The following code snippet shows how to draw a rectangle at a fixed location in a chart using XYPoint so that it is anchored to the window itself and will not scroll with the bars. In this case, the rectangle's upper left corner will be 150 pixels from the chart's left-side border and 50 pixels from the top border. The lower-right corner is 250 pixels from the left-side and 100 pixels from the top.

myXYRectangle = Rectangle.create(XYPoint.Create(150,50),XYPoint.Create(250,100));
DrawingObjects.Add(myXYRectangle);

Alternatively, you can use BNPoint to draw a rectangle between specified bar numbers or DTPoint to draw between date-time positions, so that the rectangle will scroll with the bars:

If (Currentbar = 50) then
Begin
   MyBNRectangle = Rectangle.Create(BNPoint.Create(CurrentBar + MaxBarsBack, Highest(High, 50)), BNPoint.Create(CurrentBar - 50 + MaxBarsBack, Lowest(Low, 50)));
   DrawingObjects.Add(MyBNRectangle);
End;
If (LastBarOnChart = True) then
Begin
    MyDTRectangle = Rectangle.Create(DTPoint.Create(BarDateTime[0], Highest(High, 50)), DTPoint.Create(BarDateTime[49], Lowest(Low, 50)));
    DrawingObjects.Add(MyDTRectangle);
End;

The following statements change the rectangle's border Color property (inherited from DrawingObject) to cyan while FillPattern and FillColor set the background area to solid (pattern1) red.

myRectangle.Color = elsystem.drawing.Color.Cyan;
myRectangle.FillPattern = FillPattern.pattern1;
myRectangle.FillColor = elsystem.drawing.Color.Red;

To use this in an analysis technique, be sure that it is setup as described in About Drawing Objects.

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 EndPoint object Gets the end point as a DOPoint object. See DOPoint.
Public property FillColor object Gets or sets the fill color property. See Color.
Public property FillPattern enum Gets or sets the fill pattern property using a FillPattern enumerator.
Public property StartPoint object Gets the Rectangle object start point. See DOPoint.
Public property Style enum Gets or sets the Rectangle border style using a StyleType enumerator.
Public property Weight enum Gets or sets the Rectangle border weight using a Weight enumerator.
Methods
  Name Description
Public property Create(DTPoint, DTPoint) Initializes a new instance of the Rectangle class. The first parameter is a DTPoint object representing the starting point (upper left) of the rectangle. The second parameter is a DTPoint object representing the end point (lower right).
Public property Create(DTPoint, DTPoint, int) Initializes a new instance of the Rectangle class. The first parameter is a DTPoint object representing the starting point (upper left) of the rectangle. The second parameter is a DTPoint object representing the end point (lower right), and the third parameter is an integer representing the data number (data1 - 50).
Public property Create(BNPoint, BNPoint) Initializes a new instance of the Rectangle class. The first parameter is a BNPoint object representing the starting point (upper left) of the rectangle. The second parameter is a BNPoint object representing the end point (lower right).
Public property Create(BNPoint, BNPoint, int) Initializes a new instance of the Rectangle class. The first parameter is a BNPoint object representing the starting point (upper left) of the rectangle. The second parameter is a BNPoint object representing the end point (lower right), and the third parameter is an integer representing the data number (data1 - 50).
Public property Create(XYPoint, XYPoint) Initializes a new instance of the Rectangle class. The first parameter is a XYPoint object representing the starting point of a rectangle that contains the ellipse; the second parameter is a XYPoint object representing the end point (lower right).
Public property Create(XYPoint, XYPoint, int) Initializes a new instance of the Rectangle class. The first parameter is a XYPoint object representing the starting point (upper left) of the rectangle. The second parameter is a XYPoint object representing the end point (lower right), and the third parameter is an integer representing the data number (data1 - 50).
Public property SetEndPoint(DTPoint) Sets the Rectangle end point using a DTPoint object.
Public property SetEndPoint(BNPoint) Sets the Rectangle end point using a BNPoint object.
Public property SetEndPoint(XYPoint) Sets the Rectangle end point using a XYPoint object.
Public property SetStartPoint(DTPoint) Sets the Rectangle start point using a DTPoint object.
Public property SetStartPoint(BNPoint) Sets the Rectangle start point using a BNPoint object.
Public property SetStartPoint(XYPoint) Sets the Rectangle start point using a XYPoint object.
Example

The following example shows...  

Import Example

Displays a rectangle containing text at a fixed position in the upper-right corner of a chart.

  1. Click on the Import Example link to import the example into TradeStation.   
  2. Go to the TradeStation platform and create a chart window.  Use the Insert - Indicator menu sequence and Add !ex_TextRectangle to the window.
  3. To review or modify the example code, go to the TS Development Environment and open indicator !ex_TextRectangle in the EasyLanguage Editor.
Inheritance Hierarchy

elsystem.Object

  elsystem.DrawingObject

    elsystem.DrawingObjects.Rectangle