Overlapping of staticTexts

Created at 12 Jun 2024, 09:41
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!
AlgoCreators's avatar

AlgoCreators

Joined 16.01.2022

Overlapping of staticTexts
12 Jun 2024, 09:41


Hello friends,

I want to print a text from different indicators on the chart with ChartStaticText, but the texts overlap.
I make sure that they are not the same.
Is there a solution?

         public class Sample1 : Indicator
     {
         protected override void Initialize()
         {

             Chart.DrawStaticText("Static_Sample"+this.ToString(), "First Test", VerticalAlignment.Bottom, HorizontalAlignment.Left, Color.Red);
         }
         public override void Calculate(int index)
         {
         }
     }

 

         public class Sample2 : Indicator
     {
         protected override void Initialize()
         {

             Chart.DrawStaticText("Static_Sample"+this.ToString(), "Second Test", VerticalAlignment.Bottom, HorizontalAlignment.Left, Color.Red);
         }
         public override void Calculate(int index)
         {
         }
     }

 

 


@AlgoCreators
Replies

firemyst
13 Jun 2024, 03:37

This has been like this since forever. It isn't a bug, just a use case that was never considered by the Spotware team (I'm guessing)

 

I've gotten around this by creating a static variable in my custom indicators they all reference when printing out messages. You'll have to manage thread-concurrency issues to make sure no two indicators are writing to it at the same time, but this can be easily overcome too by using a built in thread-safe structure like a ConcurrentDictionary or using global flags.

 

 


@firemyst

PanagiotisCharalampous
13 Jun 2024, 05:36

Hi there,

Another solution would be to create a new indicator referencing all others that would serve only the purpose of text printing. In this indicator, you can create a unified text message and print it.

Best regards,

Panagiotis


@PanagiotisCharalampous