Skip to content

ChartColorSettings

Summary

Represents the charts Color Settings.

Remarks

Use the Color classes to set the chart Color Settings.

Signature

1
public abstract interface ChartColorSettings

Namespace

cAlgo.API

Properties

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

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
 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)
         {
         }
     }
 }

Last update: July 1, 2022

Comments