ChartArea.DrawText
method · ChartArea · cAlgo.API
DesktopCLICloud
Draws the text.
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
| Signature |
|---|
DrawText(string name, string text, DateTime time, double y, Color color) |
DrawText(string name, string text, int barIndex, double y, Color color) |
DrawText(string name, string text, DateTime time, double y, Color color)
Draws the text.
ChartText DrawText(string name, string text, DateTime time, double y, Color color)
chartArea.DrawText(name: str, text: str, time: DateTime, y: float, color: Color) -> ChartText
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. |
text | string | str | The text content. |
time | DateTime | DateTime | The time value of the text object location on the X-axis. |
y | double | float | The Y-axis value of the text object location. |
color | Color | Color | The color of the text. |
Returns ChartText — ChartText.
Examples
// Draw the text on the last bar high.
var highPrice = Bars.HighPrices.LastValue;
var openTime = Bars.OpenTimes.LastValue;
var text = Chart.DrawText("text1", "High is here", openTime, highPrice, Color.Red);
text.VerticalAlignment = VerticalAlignment.Bottom;
text.HorizontalAlignment = HorizontalAlignment.Center;
highPrice = api.Bars.HighPrices.LastValue
openTime = api.Bars.OpenTimes.LastValue
text = api.Chart.DrawText("text1", "High is here", openTime, highPrice, Color.Red)
text.VerticalAlignment = VerticalAlignment.Bottom
text.HorizontalAlignment = HorizontalAlignment.Center
DrawText(string name, string text, int barIndex, double y, Color color)
Draws the text.
ChartText DrawText(string name, string text, int barIndex, double y, Color color)
chartArea.DrawText(name: str, text: str, barIndex: int, y: float, color: Color) -> ChartText
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. |
text | string | str | The text content. |
barIndex | int | int | The bar index of the text object location on the X-axis. |
y | double | float | The Y-axis value of the text object location. |
color | Color | Color | The color of the text. |
Returns ChartText — ChartText.
Examples
var index = Bars.Count - 1;
var text = Chart.DrawText("lowLabel", "Low", index, Bars.LowPrices[index], Color.Orange);
text.VerticalAlignment = VerticalAlignment.Top;
Print("Text drawn at {0}", text.Time);
index = api.Bars.Count - 1
text = api.Chart.DrawText("lowLabel", "Low", index, api.Bars.LowPrices[index], Color.Orange)
text.VerticalAlignment = VerticalAlignment.Top
api.Print(f"Text drawn at {text.Time}")