ChartArea.DrawRectangle
method · ChartArea · cAlgo.API
Draws a rectangle.
Environment behaviour
CLI — works differently. The object is created and returned, but never drawn: the CLI displays no chart.
Cloud — works differently. The object is created and returned, but never drawn: the cloud displays no chart.
Overloads
DrawRectangle(string name, DateTime time1, double y1, DateTime time2, double y2, Color color)
Draws a rectangle.
ChartRectangle DrawRectangle(string name, DateTime time1, double y1, DateTime time2, double y2, Color color)
chartArea.DrawRectangle(name: str, time1: DateTime, y1: float, time2: DateTime, y2: float, color: Color) -> ChartRectangle
Parameters
| Name | C# type | Python type | Description |
|---|---|---|---|
name | string | str | The chart object name - a unique name that can be only used once for a chart area. If duplicated, the chart object will be replaced with a new one of the same name. |
time1 | DateTime | DateTime | The time value of the rectangle point 1 location on the X-axis. |
y1 | double | float | The Y-axis value of the rectangle point 1 location. |
time2 | DateTime | DateTime | The time value of the rectangle point 2 location on the X-axis. |
y2 | double | float | The Y-axis value of the rectangle point 2 location. |
color | Color | Color | The rectangle lines color. |
Returns ChartRectangle — ChartRectangle.
Examples
var rectangle = Chart.DrawRectangle("zone", Bars.OpenTimes.Last(20), Bars.LowPrices.Last(20), Bars.OpenTimes.LastValue, Bars.HighPrices.LastValue, Color.FromArgb(80, Color.Blue));
rectangle.IsFilled = true;
Print("Zone from {0} to {1}", rectangle.Y1, rectangle.Y2);
rectangle = api.Chart.DrawRectangle("zone", api.Bars.OpenTimes.Last(20), api.Bars.LowPrices.Last(20), api.Bars.OpenTimes.LastValue, api.Bars.HighPrices.LastValue, Color.FromArgb(80, Color.Blue))
rectangle.IsFilled = True
api.Print(f"Zone from {rectangle.Y1} to {rectangle.Y2}")
DrawRectangle(string name, DateTime time1, double y1, DateTime time2, double y2, Color color, int thickness)
Draws a rectangle.
ChartRectangle DrawRectangle(string name, DateTime time1, double y1, DateTime time2, double y2, Color color, int thickness)
chartArea.DrawRectangle(name: str, time1: DateTime, y1: float, time2: DateTime, y2: float, color: Color, thickness: int) -> ChartRectangle
Parameters
| Name | C# type | Python type | Description |
|---|---|---|---|
name | string | str | The chart object name - a unique name that can be only used once for a chart area. If duplicated, the chart object will be replaced with a new one of the same name. |
time1 | DateTime | DateTime | The time value of the rectangle point 1 location on the X-axis. |
y1 | double | float | The Y-axis value of the rectangle point 1 location. |
time2 | DateTime | DateTime | The time value of the rectangle point 2 location on the X-axis. |
y2 | double | float | The Y-axis value of the rectangle point 2 location. |
color | Color | Color | The rectangle lines color. |
thickness | int | int | The rectangle lines thickness. |
Returns ChartRectangle — ChartRectangle.
Examples
var rectangle = Chart.DrawRectangle("zone", Bars.OpenTimes.Last(20), Bars.LowPrices.Last(20), Bars.OpenTimes.LastValue, Bars.HighPrices.LastValue, Color.Blue, 2);
Print("Zone border thickness: {0}", rectangle.Thickness);
rectangle = api.Chart.DrawRectangle("zone", api.Bars.OpenTimes.Last(20), api.Bars.LowPrices.Last(20), api.Bars.OpenTimes.LastValue, api.Bars.HighPrices.LastValue, Color.Blue, 2)
api.Print(f"Zone border thickness: {rectangle.Thickness}")
DrawRectangle(string name, DateTime time1, double y1, DateTime time2, double y2, Color color, int thickness, LineStyle lineStyle)
Draws a rectangle.
ChartRectangle DrawRectangle(string name, DateTime time1, double y1, DateTime time2, double y2, Color color, int thickness, LineStyle lineStyle)
chartArea.DrawRectangle(name: str, time1: DateTime, y1: float, time2: DateTime, y2: float, color: Color, thickness: int, lineStyle: LineStyle) -> ChartRectangle
Parameters
| Name | C# type | Python type | Description |
|---|---|---|---|
name | string | str | The chart object name - a unique name that can be only used once for a chart area. If duplicated, the chart object will be replaced with a new one of the same name. |
time1 | DateTime | DateTime | The time value of the rectangle point 1 location on the X-axis. |
y1 | double | float | The Y-axis value of the rectangle point 1 location. |
time2 | DateTime | DateTime | The time value of the rectangle point 2 location on the X-axis. |
y2 | double | float | The Y-axis value of the rectangle point 2 location. |
color | Color | Color | The rectangle lines color. |
thickness | int | int | The rectangle lines thickness. |
lineStyle | LineStyle | LineStyle | The rectangle lines style. |
Returns ChartRectangle — ChartRectangle.
Examples
var rectangle = Chart.DrawRectangle("zone", Bars.OpenTimes.Last(20), Bars.LowPrices.Last(20), Bars.OpenTimes.LastValue, Bars.HighPrices.LastValue, Color.Blue, 2, LineStyle.Dots);
Print("Zone border style: {0}", rectangle.LineStyle);
rectangle = api.Chart.DrawRectangle("zone", api.Bars.OpenTimes.Last(20), api.Bars.LowPrices.Last(20), api.Bars.OpenTimes.LastValue, api.Bars.HighPrices.LastValue, Color.Blue, 2, LineStyle.Dots)
api.Print(f"Zone border style: {rectangle.LineStyle}")
DrawRectangle(string name, int barIndex1, double y1, int barIndex2, double y2, Color color)
Draws a rectangle.
ChartRectangle DrawRectangle(string name, int barIndex1, double y1, int barIndex2, double y2, Color color)
chartArea.DrawRectangle(name: str, barIndex1: int, y1: float, barIndex2: int, y2: float, color: Color) -> ChartRectangle
Parameters
| Name | C# type | Python type | Description |
|---|---|---|---|
name | string | str | The chart object name - a unique name that can be only used once for a chart area. If duplicated, the chart object will be replaced with a new one of the same name. |
barIndex1 | int | int | The bar index of the rectangle point 1 location on the X-axis. |
y1 | double | float | The Y-axis value of the rectangle point 1 location. |
barIndex2 | int | int | The bar index of the rectangle point 2 location on the X-axis. |
y2 | double | float | The Y-axis value of the rectangle point 2 location. |
color | Color | Color | The rectangle lines color. |
Returns ChartRectangle — ChartRectangle.
Examples
var index = Bars.Count - 1;
var rectangle = Chart.DrawRectangle("zone", index - 20, Bars.LowPrices[index - 20], index, Bars.HighPrices[index], Color.FromArgb(80, Color.Blue));
rectangle.IsFilled = true;
Print("Zone from {0} to {1}", rectangle.Y1, rectangle.Y2);
index = api.Bars.Count - 1
rectangle = api.Chart.DrawRectangle("zone", index - 20, api.Bars.LowPrices[index - 20], index, api.Bars.HighPrices[index], Color.FromArgb(80, Color.Blue))
rectangle.IsFilled = True
api.Print(f"Zone from {rectangle.Y1} to {rectangle.Y2}")
DrawRectangle(string name, int barIndex1, double y1, int barIndex2, double y2, Color color, int thickness)
Draws a rectangle.
ChartRectangle DrawRectangle(string name, int barIndex1, double y1, int barIndex2, double y2, Color color, int thickness)
chartArea.DrawRectangle(name: str, barIndex1: int, y1: float, barIndex2: int, y2: float, color: Color, thickness: int) -> ChartRectangle
Parameters
| Name | C# type | Python type | Description |
|---|---|---|---|
name | string | str | The chart object name - a unique name that can be only used once for a chart area. If duplicated, the chart object will be replaced with a new one of the same name. |
barIndex1 | int | int | The bar index of the rectangle point 1 location on the X-axis. |
y1 | double | float | The Y-axis value of the rectangle point 1 location. |
barIndex2 | int | int | The bar index of the rectangle point 2 location on the X-axis. |
y2 | double | float | The Y-axis value of the rectangle point 2 location. |
color | Color | Color | The rectangle lines color. |
thickness | int | int | The rectangle lines thickness. |
Returns ChartRectangle — ChartRectangle.
Examples
var index = Bars.Count - 1;
var rectangle = Chart.DrawRectangle("zone", index - 20, Bars.LowPrices[index - 20], index, Bars.HighPrices[index], Color.Blue, 2);
Print("Zone border thickness: {0}", rectangle.Thickness);
index = api.Bars.Count - 1
rectangle = api.Chart.DrawRectangle("zone", index - 20, api.Bars.LowPrices[index - 20], index, api.Bars.HighPrices[index], Color.Blue, 2)
api.Print(f"Zone border thickness: {rectangle.Thickness}")
DrawRectangle(string name, int barIndex1, double y1, int barIndex2, double y2, Color color, int thickness, LineStyle lineStyle)
Draws a rectangle.
ChartRectangle DrawRectangle(string name, int barIndex1, double y1, int barIndex2, double y2, Color color, int thickness, LineStyle lineStyle)
chartArea.DrawRectangle(name: str, barIndex1: int, y1: float, barIndex2: int, y2: float, color: Color, thickness: int, lineStyle: LineStyle) -> ChartRectangle
Parameters
| Name | C# type | Python type | Description |
|---|---|---|---|
name | string | str | The chart object name - a unique name that can be only used once for a chart area. If duplicated, the chart object will be replaced with a new one of the same name. |
barIndex1 | int | int | The bar index of the rectangle point 1 location on the X-axis. |
y1 | double | float | The Y-axis value of the rectangle point 1 location. |
barIndex2 | int | int | The bar index of the rectangle point 2 location on the X-axis. |
y2 | double | float | The Y-axis value of the rectangle point 2 location. |
color | Color | Color | The rectangle lines color. |
thickness | int | int | The rectangle lines thickness. |
lineStyle | LineStyle | LineStyle | The rectangle lines style. |
Returns ChartRectangle — ChartRectangle.
Examples
var index = Bars.Count - 1;
var rectangle = Chart.DrawRectangle("zone", index - 20, Bars.LowPrices[index - 20], index, Bars.HighPrices[index], Color.Blue, 2, LineStyle.Dots);
Print("Zone border style: {0}", rectangle.LineStyle);
index = api.Bars.Count - 1
rectangle = api.Chart.DrawRectangle("zone", index - 20, api.Bars.LowPrices[index - 20], index, api.Bars.HighPrices[index], Color.Blue, 2, LineStyle.Dots)
api.Print(f"Zone border style: {rectangle.LineStyle}")