Skip to content

Control.ForegroundColor

property · Control · cAlgo.API

DesktopCLICloud

Gets or sets the color of the chart control foreground. Check the Color class for the ARGB (alpha, red, green, blue) color values, or use the strings Color.Red, Color.FromName("Red"), Color.FromArgb(255, 0, 0), Color.FromHex("#ff0000"), "Red", "#ff0000".

Environment behaviour

CLI — not supported. Accepted without error but never displayed, so control events such as Click are never raised.

Cloud — not supported. Accepted without error but never displayed, so control events such as Click are never raised.

Definition

public Color ForegroundColor {get; set;}
control.ForegroundColor: Color

Returns Color

Examples

var profit = Positions.Sum(position => position.NetProfit);
var textBlock = new TextBlock { Text = "Net profit: " + profit.ToString("F2") };
textBlock.ForegroundColor = profit >= 0 ? Color.LimeGreen : Color.Red;
Chart.AddControl(textBlock);
profit = sum(position.NetProfit for position in api.Positions)
textBlock = TextBlock()
textBlock.Text = f"Net profit: {profit:.2f}"
textBlock.ForegroundColor = Color.LimeGreen if profit >= 0 else Color.Red
api.Chart.AddControl(textBlock)