Value from Obj_Vline


I guys i need small help for code. I want to obtain time value from vertical object line and have it subtracted from my other vertical bar.

I want this to update based on Chart event.

double times=TimeToStr(ObjectGetTimeByValue(0,tline1 ,Bid,0)

this above line i have assumed will get time value based on Bid of Tline1.

double diff = TimeToStr(ObjectGetTimeByValue(0,tline1i ,Bid,0)-times);
This above line i have assumed will find time value based on Bid price of tline1i and then subtract this from above value…

but this renders to zero value.

Why did you declare times as double but then set its value to string?

Declare as datetime and when you deal with time, know that everything is in seconds elapsed since January 01 1970

well i made script to add just trend line with given fixed length so saved all the trouble of this.