How to draw that trendline?

 

Hello to Everyone!

I would like to draw a trendline with

ObjectCreate("trendline",OBJ_TREND,0,time1,price1,time2,price2,0,0);

I have the time1 in that format: 2011.10.03 18:12

and time2 in the same format: 2011.10.03 20:12

Price1 and price2 are in a normal double format.

Does someone know a way to things together so the trendline can be drawn as described? Somehow I need to convert the date and time into a sting into a double.

Thanks for any help and greetings,

APeng.

 
APeng:

Somehow I need to convert the date and time into a sting into a double.

Convert ? did you check the conversion functions ? Maybe StrToTime ?
 

StrToTime could work, if it converts the decribed format into a usable format for ObjectCreate.

I try it out, thx for the hint!

 

I'd be interested to know why you would have any doubts that it would work ? did you read the documentation for StrToTime and ObjectCreate ?

StrToTime . . . "Converts string in the format "yyyy.mm.dd hh:mi" to datetime type" so it returns a datetime, ObjectCreate needs datetime types for it time1, 2 & 3 values . . .

Reason: