Placing text on chart with fixed distance from last candel

 

Hi


I made a small code to place remaining candle time to be displayed on the chart

Now I use this code

ObjectCreate("time", OBJ_TEXT, 0, Time[0] + 1750.000, Close[0] + 15.000);


The line below simple places the text 1750 units to the right from the last candle.

Time[0] + 1750.000


Issue witht this is that when you zoom in or out this distance remains the same.
The text will overlap the candle when zoomed out enough

I would like to have the text stay the same distance from the last candle no matter how far is zoomed in or out.

Does anyone know how to fix this?

What might work and be an easy fix is to align the the from the left and not from the middle what it is doing now

Does anyone know a way to align (starting point of the text) the text from the left instead of the middle?

Thanks in advance
Regards

 
For text sticked to a price and time, use obj_lavel.
In order to estimate the time delta between the text and candle, you can use PeriodSeconds() in order to estimate the width of one candle in seconds. Then you can add half a candle to the text distance away.

I hope this helps