datetime help

 
I am trying to get the datetime of an object on the chart then add to that datetime. 
NewTimes =  ObjectGetTimeByValue(0, "start time1", 1, 0);

TimeToAdd=365*60; //convert to seconds

NewTime=NewTimes+TimeToAdd;   // Change time to datetime from string(hh:mm) format and carry out addition

NewEasyToReadTime=TimeToStr(NewTime);

Thats what I have so far. Did some searching but I can't seem to get it to work

 
  1. "Doesn't work" is meaningless — just like saying the car doesn't work. Doesn't start, won't go in gear, no electrical, missing the key, flat tires — meaningless.

  2. Is your object a trendline (or one of the other types listed at ObjectGetTimeByValue - Object Functions - MQL4 Reference)?
  3. Does it actually pass through the value one?
  4. Are you sure you want to add 6.083 hours?
 
The object is a vertical line. My understanding was that it would get the time value at price level one of my object. But now I’m starting to think that the objectgettimebyvalue doesn’t retrieve a date as well
 
gunterd2:
The object is a vertical line. My understanding was that it would get the time value at price level one of my object. But now I’m starting to think that the objectgettimebyvalue doesn’t retrieve a date as well

Elaborating on the answer which you've already been given, above...

ObjectGetTimeByValue is intended for things like trend lines, giving you the time value which equates to a price somewhere on the trend line. To get the time value of something like a horizontal line, use:

datetime tm = (datetime)ObjectGetInteger(0, name, OBJPROP_TIME1);

You're then adding 365x60 = 21,900 seconds to the value, or a little over 6 hours. These seems unlikely to be what you intend.

 
JC:

Elaborating on the answer which you've already been given, above...

ObjectGetTimeByValue is intended for things like trend lines, giving you the time value which equates to a price somewhere on the trend line. To get the time value of something like a horizontal line, use:

You're then adding 365x60 = 21,900 seconds to the value, or a little over 6 hours. These seems unlikely to be what you intend.

Should be "vertical". An horizontal line doesn't have a time.

 
Alain Verleyen:

Should be "vertical". An horizontal line doesn't have a time.

You're obviously right in any meaningful sense. But in a pedantic sense you're wrong. If you create a horizontal line manually (rather than through code), then it does have a time value: the time of the bar which you make the single click on to create the line.

 
JC:

You're obviously right in any meaningful sense. But in a pedantic sense you're wrong. If you create a horizontal line manually (rather than through code), then it does have a time value: the time of the bar which you make the single click on to create the line.

lool, you are right. Have ever found a usage for this feature ?
 
I’m just trying to get the datetime of a vertical line
 
gunterd2:
I’m just trying to get the datetime of a vertical line

See above.

 
Alain Verleyen:
lool, you are right. Have ever found a usage for this feature ?

No. I'm just trying to find a retrospective justification for stupidly writing "horizontal" instead of "vertical".

 
JC:

No. I'm just trying to find a retrospective justification for stupidly writing "horizontal" instead of "vertical".

Reason: