ChartColorSettings
interface cAlgo.API
DesktopCLICloud
Represents the charts Color Settings.
Definition
public interface ChartColorSettings
Namespace: cAlgo.API · Group: Chart
Remarks
Use the Color classes to set the chart Color Settings.
Examples
using cAlgo.API;
namespace cAlgo
{
// This indicator allows you to change chart colors via chart controls
public partial 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)
{
}
}
}
import clr
clr.AddReference("cAlgo.API")
from cAlgo.API import *
class Test():
def get_text_block(self, text):
textBlock = TextBlock()
textBlock.Text = text
textBlock.Style = self.style
return textBlock
def get_color(self, colorString, alpha = 255):
color = Color.FromHex(colorString) if colorString[0] == '#' else Color.FromName(colorString)
return Color.FromArgb(alpha, color)
def on_change_button_clicked(self, args):
api.Chart.ColorSettings.AskPriceLineColor = self.get_color(self.askPriceLineColorTextBox.Text)
api.Chart.ColorSettings.BidPriceLineColor = self.get_color(self.bidPriceLineColorTextBox.Text)
api.Chart.ColorSettings.BackgroundColor = self.get_color(self.backgroundColorTextBox.Text)
def initialize(self):
grid = Grid(10, 2)
grid.BackgroundColor = Color.Gold
grid.Opacity = 0.6
grid.HorizontalAlignment = HorizontalAlignment.Left
grid.VerticalAlignment = VerticalAlignment.Bottom
self.style = Style()
self.style.Set(ControlProperty.Margin, 5)
self.style.Set(ControlProperty.FontWeight, FontWeight.ExtraBold)
self.style.Set(ControlProperty.ForegroundColor, Color.Red)
self.style.Set(ControlProperty.MinWidth, 100)
grid.AddChild(self.get_text_block("Ask Price Line Color"), 0, 0)
self.askPriceLineColorTextBox = self.get_text_block(str(api.Chart.ColorSettings.AskPriceLineColor))
grid.AddChild(self.askPriceLineColorTextBox, 0, 1)
grid.AddChild(self.get_text_block("Bid Price Line Color"), 1, 0)
self.bidPriceLineColorTextBox = self.get_text_block(str(api.Chart.ColorSettings.BidPriceLineColor))
grid.AddChild(self.bidPriceLineColorTextBox, 1, 1)
grid.AddChild(self.get_text_block("Background Color"), 2, 0)
self.backgroundColorTextBox = self.get_text_block(str(api.Chart.ColorSettings.BackgroundColor))
grid.AddChild(self.backgroundColorTextBox, 2, 1)
changeButton = Button()
changeButton.Text = "Change"
changeButton.Style = self.style
changeButton.Click += self.on_change_button_clicked
grid.AddChild(changeButton, 9, 0)
api.Chart.AddControl(grid)
{
"AccessRights": "None",
"TimeZone": "UTC",
"IsOverlay": true
}
Properties
| Name | Description |
|---|---|
AreaFillColorDesktopCLICloudColor | Gets or sets the color of area chart fill. |
AskPriceLineColorDesktopCLICloudColor | Gets or sets the color of the ask price line. |
BackgroundColorDesktopCLICloudColor | Gets or sets the color of the chart background. |
BearFillColorDesktopCLICloudColor | Gets or sets the color of the bear candle fill. |
BearOutlineColorDesktopCLICloudColor | Gets or sets the color of the bear candle or bar outline. |
BidPriceLineColorDesktopCLICloudColor | Gets or sets the color of the bid price line. |
BullFillColorDesktopCLICloudColor | Gets or sets the color of the bull candle fill. |
BullOutlineColorDesktopCLICloudColor | Gets or sets the color of the bull candle or bar outline. |
BuyColorDesktopCLICloudColor | Gets or sets the color of Buy positions and orders. |
ForegroundColorDesktopCLICloudColor | Gets or sets the color of the chart foreground. |
GridLinesColorDesktopCLICloudColor | Gets or sets the color of the grid lines. |
LosingDealColorDesktopCLICloudColor | Gets or sets the color of the losing deal. |
PeriodSeparatorColorDesktopCLICloudColor | Gets or sets the color of the period separator. |
SellColorDesktopCLICloudColor | Gets or sets the color of Sell order positions and orders. |
TickVolumeColorDesktopCLICloudColor | Gets or sets the color of the tick volume. |
WinningDealColorDesktopCLICloudColor | Gets or sets the color of the winning deal. |