Skip to content

ChartText

interface cAlgo.API

DesktopCLICloud

Represents the Text chart object. Allows place the text anywhere on the chart, bound to the chart.

Environment behaviour

CLI — works differently. Created and kept with all its properties, but never drawn: the CLI displays no chart.

Cloud — works differently. Created and kept with all its properties, but never drawn: the cloud displays no chart.

Definition

public interface ChartText

Namespace: cAlgo.API · Group: Drawings · Implements: ChartObject

Examples

using cAlgo.API;

namespace cAlgo
{
    // This sample shows how to use Chart.DrawText method to draw text
    public partial class ChartTextSample : Indicator
    {
        protected override void Initialize()
        {
            for (int iBarIndex = Chart.FirstVisibleBarIndex; iBarIndex <= Chart.LastVisibleBarIndex; iBarIndex++)
            {
                string text;

                double y;

                Color color;

                if (Bars.ClosePrices[iBarIndex] > Bars.OpenPrices[iBarIndex])
                {
                    text = "U";
                    y = Bars.LowPrices[iBarIndex];
                    color = Color.Green;
                }
                else
                {
                    text = "D";
                    y = Bars.HighPrices[iBarIndex];
                    color = Color.Red;
                }

                Chart.DrawText("Text_" + iBarIndex, text, iBarIndex, y, color);
            }
        }

        public override void Calculate(int index)
        {
        }
    }
}
for barIndex in range(api.Chart.FirstVisibleBarIndex, api.Chart.LastVisibleBarIndex + 1):
    if api.Bars.ClosePrices[barIndex] > api.Bars.OpenPrices[barIndex]:
        api.Chart.DrawText(f"Text_{barIndex}", "U", barIndex, api.Bars.LowPrices[barIndex], Color.Green)
    else:
        api.Chart.DrawText(f"Text_{barIndex}", "D", barIndex, api.Bars.HighPrices[barIndex], Color.Red)
{
  "AccessRights": "None",
  "TimeZone": "UTC",
  "IsOverlay": true
}

Properties

Name Description
AngleDesktopCLIClouddouble Gets or sets the rotation angle of the text in degrees, measured clockwise around the text anchor point. The text can be fully rotated; any value is accepted and normalized to the 0 to 360 range. The default value is 0, which renders horizontal text.
ColorDesktopCLICloudColor Gets or sets the text color.
FontFamilyDesktopCLICloudstring Gets or sets the font style of the text.
FontSizeDesktopCLIClouddouble Gets or sets the font size of text
HorizontalAlignmentDesktopCLICloudHorizontalAlignment Gets or sets the horizontal alignment of the text regarding the anchor point.
IsBoldDesktopCLICloudbool Gets or sets if the text is Bold or not
IsItalicDesktopCLICloudbool Gets or sets if the text is Italic or not
IsUnderlinedDesktopCLICloudbool Gets or sets if the text is Underlined or not
TextDesktopCLICloudstring Gets or sets the text content.
TimeDesktopCLICloudDateTime Gets or sets the Time line value.
VerticalAlignmentDesktopCLICloudVerticalAlignment Gets or sets the vertical alignment of the text regarding the anchor point.
YDesktopCLIClouddouble Gets or sets the Y-axis value.

Inherited members

From ChartObject: Name, Comment, ObjectType, IsInteractive, IsLocked, IsHidden, ZIndex, IsAlive

See also