Printing/Showing cBot data on the screen

Created at 24 May 2021, 21:28
How’s your experience with the cTrader Platform?
Your feedback is crucial to cTrader's development. Please take a few seconds to share your opinion and help us improve your trading experience. Thanks!
TR

tradeandinvest31

Joined 02.05.2021

Printing/Showing cBot data on the screen
24 May 2021, 21:28


Hi guys, 

I found the following article that shows text being printed onto the screen via a cBot. 

DrawText via cBot

public Symbol[] MySymbols;

protected override void OnStart()
{
    MySymbols = Symbols.GetSymbols("EURUSD", "GBPUSD", "USDJPY", "USDCHF");
    foreach (var symbol in MySymbols)
    {
        symbol.Tick += Symbol_Tick;
    }
}

private void Symbol_Tick(SymbolTickEventArgs obj)
{
    var sb = new StringBuilder();
    foreach (var symbol in MySymbols)
    {
        var textLine = string.Format("{0} {1} {2}", symbol.Name, symbol.Bid, symbol.Ask);
        sb.AppendLine(textLine);
    }
    Chart.DrawStaticText("symbols", sb.ToString(), VerticalAlignment.Top, HorizontalAlignment.Left, Chart.ColorSettings.ForegroundColor);
}

I wanted to replicate this but instead of showing multiple symbols, i wanted to display other information. I've attempted to run the above code but with no success.

Could you please advise how i would add text to a chart via a cBot?

Many Thanks, 


@tradeandinvest31
Replies

PanagiotisCharalampous
25 May 2021, 08:28

Hi tradeandinvest31,

Can you please share your code and explain what the problem is?

Best Regards,

Panagiotis 

Join us on Telegram


@PanagiotisCharalampous