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
|
Name |
Description |
|
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). |
|
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). |
|
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). |
|
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). |
|
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). |
|
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). |
|
SetEndPoint(DTPoint) |
Sets the Rectangle end point using a DTPoint object. |
|
SetEndPoint(BNPoint) |
Sets the Rectangle end point using a BNPoint object. |
|
SetEndPoint(XYPoint) |
Sets the Rectangle end point using a XYPoint object. |
|
SetStartPoint(DTPoint) |
Sets the Rectangle start point using a DTPoint object. |
|
SetStartPoint(BNPoint) |
Sets the Rectangle start point using a BNPoint object. |
|
SetStartPoint(XYPoint) |
Sets the Rectangle start point using a XYPoint object. |
The following example
shows...
Import Example
|
Displays a rectangle containing text at a fixed position in the upper-right corner of a chart.
|
- Click
on the Import Example link to import the example into TradeStation.
- Go
to the TradeStation platform and create a chart window. Use
the Insert - Indicator menu sequence and Add !ex_TextRectangle to the window.
- To review
or modify the example code, go to the TS Development Environment
and open indicator !ex_TextRectangle in the
EasyLanguage Editor.