How can a difference in the first argument (object name) using Chart.DrawText() cause a difference in the location of the text?

Created at 08 Jul 2020, 09:36
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!
FA

fang0092

Joined 08.06.2019

How can a difference in the first argument (object name) using Chart.DrawText() cause a difference in the location of the text?
08 Jul 2020, 09:36


I was playing around with the arguments of Chart.DrawText and found that although all the arguments except the object ID are the same, the location of the text is different.

Why is the output of line abc different compared to the last line xyz?

 

line abc - Chart.DrawText(string.Concat("id-", themid), "abc", index, 45, Color.White);

line xyz - Chart.DrawText("wh", "abc", index, 45, Color.White);


@fang0092
Replies

PanagiotisCharalampous
08 Jul 2020, 09:41

Hi francisang92,

You need to have a unique name for each object. Else when the DrawText() is called using the name of an existing object, the object will be replaced with the new one.

Best Regards,

Panagiotis 

Join us on Telegram

 


@PanagiotisCharalampous

fang0092
08 Jul 2020, 09:52

RE:

PanagiotisCharalampous said:

Hi francisang92,

You need to have a unique name for each object. Else when the DrawText() is called using the name of an existing object, the object will be replaced with the new one.

Best Regards,

Panagiotis 

Join us on Telegram

 

So code on line xyz creates a text, but since it has the same object ID, it keeps getting overwritten. Text only appears at the last bar, because nothing else is replacing.

Ok. Thank you. 


@fang0092