Printing text on chart from robots

Created at 25 Aug 2017, 19:44
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!
irmscher9's avatar

irmscher9

Joined 22.12.2016

Printing text on chart from robots
25 Aug 2017, 19:44


Hey guys, 

Can anyone please give me an example of code of how to print text on a chart from a robot (not indicator)

Cheers :)


@irmscher9
Replies

Spotware
28 Aug 2017, 09:41

Dear irmscher9,

Check this example to see how to draw text on a chart. Let us know if this is helpful.

Best Regards,

cTrader Team

 


@Spotware

irmscher9
28 Aug 2017, 12:37

Thanks for prompt reply.

Does it work with indicators only or both indicators and bots?

If it works with bots, could you please give me an example of a simple bot that prints text in a certain places on a chart?


@irmscher9

Spotware
28 Aug 2017, 12:49

Dear irmscher9,

It works for cBots as well. See an example below

using System;
using System.Linq;
using cAlgo.API;
using cAlgo.API.Indicators;
using cAlgo.API.Internals;
using cAlgo.Indicators;

namespace cAlgo
{
    [Robot(TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
    public class NewcBot : Robot
    {
        [Parameter(DefaultValue = 0.0)]
        public double Parameter { get; set; }

        protected override void OnStart()
        {

        }

        protected override void OnBar()
        {
            ChartObjects.DrawText("Sample Text", "Sample Text", StaticPosition.Center);
        }

        protected override void OnStop()
        {
            
        }
    }
}

Best Regards,

cTrader Team


@Spotware

irmscher9
28 Aug 2017, 12:54

Wow, thanks a lot! Lightning-fast reply :)


@irmscher9

irmscher9
28 Aug 2017, 13:01

Hey, but does it work in backtesting?


@irmscher9

Spotware
28 Aug 2017, 14:38

Hi irmscher9,

No this function is not supposed to work in backtesting.

Best Regards,

cTrader Team


@Spotware

irmscher9
28 Aug 2017, 14:43

RE:

Spotware said:

Hi irmscher9,

No this function is not supposed to work in backtesting.

Best Regards,

cTrader Team

Hey, it would be mega useful to have this feature in backtasting. What do you think?


@irmscher9

Spotware
28 Aug 2017, 14:51

Hi irmscher9,

We will forward your suggestion to the product team for consideration.

Best Regards,

cTrader Team


@Spotware

irmscher9
28 Aug 2017, 14:51

RE:

Spotware said:

Hi irmscher9,

We will forward your suggestion to the product team for consideration.

Best Regards,

cTrader Team

Thanks. How may I track the response?


@irmscher9

Spotware
28 Aug 2017, 14:53

RE: RE:

irmscher9 said:

Spotware said:

Hi irmscher9,

We will forward your suggestion to the product team for consideration.

Best Regards,

cTrader Team

Thanks. How may I track the response?

In case they decide to implement this feature, we will update this post and you will get notified.


@Spotware

irmscher9
28 Aug 2017, 14:58

Ok, thanks.


@irmscher9

koktos632
23 Jul 2020, 10:08

RE:

The link is broken
"The server returned a "404 Not Found". "

How to draw the text on the chart?
The documentation does not provide any useful info about it :(

 

Spotware said:

Dear irmscher9,

Check this example to see how to draw text on a chart. Let us know if this is helpful.

Best Regards,

cTrader Team

 

 


@koktos632

koktos632
24 Jul 2020, 07:39

RE: RE:

Hi!

How to draw the text on the chart, please?
 


@koktos632

PanagiotisCharalampous
24 Jul 2020, 08:18

Hi koktos632,

You can use DrawText() method.

Best Regards,

Panagiotis 

Join us on Telegram

 


@PanagiotisCharalampous