ChartText


Summary

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

Syntax

public interface ChartText : ChartObject

Members

NameTypeSummary
Color PropertyGets or sets the text color.
FontSize Property
HorizontalAlignment PropertyGets or sets the horizontal alignment of the text regarding the anchor point.
IsBold Property
IsItalic Property
IsUnderlined Property
Text PropertyGets or sets the text content.
Time PropertyGets or sets the Time line value.
VerticalAlignment PropertyGets or sets the vertical alignment of the text regarding the anchor point.
Y PropertyGets or sets the Y-axis value.

Example 1

using cAlgo.API;
namespace cAlgo
{
    // This sample shows how to use Chart.DrawText method to draw text
    [Indicator(IsOverlay = true, TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
    public 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)
        {
        }
    }
}
Reference