How do I work out accurate time placement?

 

I want to place a text object 23% the distance between two time points on a trend line, on a daily chart. I get the time of each end point on the trend line using: Time1=ObjectGet("t1", OBJPROP_TIME1), Time2=ObjectGet("t1", OBJPROP_TIME2) then work out the 23% distance using: Time23 = Time1+(Time2-Time1)*0.236. I use ObjectCreate to place the text at Time23. But the text object is not placed at the correct place it is shifted to far to the right. How can I place it at the correct place?


Thanks, Steve

 

You may be having a problem with weekends.

 

Hi Phy,


Thanks for your reply.

Is there a function that automatically takes into account the weekends or works out how many weekends there are between two points in time?, I have tried to work it out but its not easy to do.


Thanks Steve

 
When dealing with past time, convert your times to bar index numbers for the calculation. For future time, you have to work out where the weekend falls manually (in your code).
 

Hi Phy,


Yes that was my think too, I was hoping there was an easier way. You can get a rough estimate by saying there are 604800 seconds in a week and dividing by that but you also have to work out which day of the week each end of the trend line falls on, to see how far through the week it is, I guess you also need to work out which day of the week Time23 falls on too


Thanks, Steve