The following code snippet is a fully working cTrader Indicator displaying the chart's current spread. The control's position, colours, and size are fully customizable.

Download ⬇️
using cAlgo.API;
namespace cAlgo
{
[Indicator(IsOverlay = true, AccessRights = AccessRights.None)]
public class SpreadDisplay : Indicator
{
[Parameter("Horizontal Position", DefaultValue = HorizontalAlignment.Center)]
public HorizontalAlignment HPosition { get; set; }
[Parameter("Vertical Position", DefaultValue = VerticalAlignment.Bottom)]
public VerticalAlignment VPosition { get; set; }
[Parameter("Foreground Color", DefaultValue = "White")]
public Color ForeColor { get; set; }
[Parameter("Background Color", DefaultValue = "Green")]
public Color BackColor { get; set; }
[Parameter("Font Size", DefaultValue = 14)]
public int FontSize { get; set; }
private TextBlock spreadText;
protected override void Initialize()
{
spreadText = new TextBlock
{
Text = "",
ForegroundColor = ForeColor,
BackgroundColor = BackColor,
FontSize = FontSize,
HorizontalAlignment = HPosition,
VerticalAlignment = VPosition,
Margin = new Thickness(10, 10, 10, 10), // Add spacing from edges
Padding = new Thickness(10) // Add internal padding between background and text
};
Chart.AddControl(spreadText);
}
public override void Calculate(int index)
{
double spread = (Symbol.Ask - Symbol.Bid) / Symbol.PipSize;
spreadText.Text = $"Spread: {spread:F1} pips";
}
}
}