ChartColorSettings


Summary

Represents the charts Color Settings.

Remarks

Use the Color classes to set the chart Color Settings.

Syntax

public interface ChartColorSettings

Members

NameTypeSummary
AskPriceLineColor PropertyGets or sets the color of the ask price line.
BackgroundColor PropertyGets or sets the color of the chart background.
BearFillColor PropertyGets or sets the color of the bear candle fill.
BearOutlineColor PropertyGets or sets the color of the bear candle or bar outline.
BidPriceLineColor PropertyGets or sets the color of the bid price line.
BullFillColor PropertyGets or sets the color of the bull candle fill.
BullOutlineColor PropertyGets or sets the color of the bull candle or bar outline.
BuyColor PropertyGets or sets the color of Buy positions and orders.
ForegroundColor PropertyGets or sets the color of the chart foreground.
GridLinesColor PropertyGets or sets the color of the grid lines.
LosingDealColor PropertyGets or sets the color of the losing deal.
PeriodSeparatorColor PropertyGets or sets the color of the period separator.
SellColor PropertyGets or sets the color of Sell order positions and orders.
TickVolumeColor PropertyGets or sets the color of the tick volume.
WinningDealColor PropertyGets or sets the color of the winning deal.

Example 1

using cAlgo.API;
namespace cAlgo
{
    // This indicator allows you to change chart colors via chart controls
    [Indicator(IsOverlay = true, TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
    public class ChartColorSettingsSample : Indicator
    {
        private TextBox _askPriceLineColorTextBox;
        private TextBox _bidPriceLineColorTextBox;
        private TextBox _backgroundColorTextBox;
        protected override void Initialize()
        {
            var grid = new Grid(10, 2)
            {
                BackgroundColor = Color.Gold,
                Opacity = 0.6,
                HorizontalAlignment = HorizontalAlignment.Left,
                VerticalAlignment = VerticalAlignment.Bottom
            };
            var style = new Style();
            style.Set(ControlProperty.Margin, 5);
            style.Set(ControlProperty.FontWeight, FontWeight.ExtraBold);
            style.Set(ControlProperty.ForegroundColor, Color.Red);
            style.Set(ControlProperty.MinWidth, 100);
            grid.AddChild(new TextBlock
            {
                Text = "Ask Price Line Color",
                Style = style
            }, 0, 0);
            _askPriceLineColorTextBox = new TextBox
            {
                Text = Chart.ColorSettings.AskPriceLineColor.ToString(),
                Style = style
            };
            grid.AddChild(_askPriceLineColorTextBox, 0, 1);
            grid.AddChild(new TextBlock
            {
                Text = "Bid Price Line Color",
                Style = style
            }, 1, 0);
            _bidPriceLineColorTextBox = new TextBox
            {
                Text = Chart.ColorSettings.BidPriceLineColor.ToString(),
                Style = style
            };
            grid.AddChild(_bidPriceLineColorTextBox, 1, 1);
            grid.AddChild(new TextBlock
            {
                Text = "Background Color",
                Style = style
            }, 2, 0);
            _backgroundColorTextBox = new TextBox
            {
                Text = Chart.ColorSettings.BackgroundColor.ToString(),
                Style = style
            };
            grid.AddChild(_backgroundColorTextBox, 2, 1);
            var changeButton = new Button
            {
                Text = "Change",
                Style = style
            };
            changeButton.Click += ChangeButton_Click;
            grid.AddChild(changeButton, 9, 0);
            Chart.AddControl(grid);
        }
        private void ChangeButton_Click(ButtonClickEventArgs obj)
        {
            Chart.ColorSettings.AskPriceLineColor = GetColor(_askPriceLineColorTextBox.Text);
            Chart.ColorSettings.BidPriceLineColor = GetColor(_bidPriceLineColorTextBox.Text);
            Chart.ColorSettings.BackgroundColor = GetColor(_backgroundColorTextBox.Text);
        }
        private Color GetColor(string colorString, int alpha = 255)
        {
            var color = colorString[0] == '#' ? Color.FromHex(colorString) : Color.FromName(colorString);
            return Color.FromArgb(alpha, color);
        }
        public override void Calculate(int index)
        {
        }
    }
}
Reference