Is there a way to display text on a black rectangle on chart where the rectangle is the exact width of the text it's under?
Is there a way to display text on a black rectangle on chart where the rectangle is the exact width of the text it's under?
09 Jun 2022, 08:24
HI all:
So I'm writing text to the chart, but find it difficult to find a text color that nicely contrasts with all the other colors on the chart (eg, candle colors, indicator colors, etc) that all text is always easily readable.
What I'd like to do is set the text on a black (or other color) rectangle so that the text is crystal clear sitting on a solid background.
What I'm having issues with is getting the length of the text being written so I know how long to make the rectangles they're sitting on.
And then adjusting the length of those rectangles (or whatever) as the text changes (gets shorter or longer as info changes)
Is there a way to get the length of the text as it's drawn on the chart so that I can then make the corresponding rectangle the corresponding width so it fits precisely underneath the text without having to stretch across the whole chart?
I'm not set on it being a rectangle - I'm open to other options that will give me a solid background and hide bars/indicators/everything else underneath it.
Thank you
amusleh
09 Jun 2022, 09:44
Hi,
You can't do this with Chart objects, but you can use controls:
The problem with controls is that they are static, so you can't get the same behavior like a ChartText object.
@amusleh