Draw a horizontal line from Time A to Time B using Date Time as Anchor point.MQL4

 

Hello,

How do you do that using Object create?


thanks

 
toksis:

Hello,

How do you do that using Object create?


thanks

OBJ_HLINE uses price as an input.

OBJ_TREND uses time and price


https://docs.mql4.com/objects

Object Functions - MQL4 Reference
Object Functions - MQL4 Reference
  • docs.mql4.com
Object Functions - MQL4 Reference
 
toksis: How do you do that using Object create?

Perhaps you should read the manual. MQL4 ReferenceObjectCreateENUM_OBJECTOBJ_TREND → example code.
   How To Ask Questions The Smart Way. (2004)
      How To Interpret Answers.
         RTFM and STFW: How To Tell You've Seriously Screwed Up.

 

What I mean is the anchor points.


I think this is my problem. How to use datetime as anchor points. Let just say   first coordinate is 930 AM london time. Then my second coordinate is 5 pm london time.

OBJPROP_TIME1 0 datetime Value to set/get first coordinate time part.        
OBJPROP_TIME2 2 datetime Value to set/get second coordinate time part.
 
toksis #:

What I mean is the anchor points.


I think this is my problem. How to use datetime as anchor points. Let just say   first coordinate is 930 AM london time. Then my second coordinate is 5 pm london time.

OBJPROP_TIME1 0 datetime Value to set/get first coordinate time part.        
OBJPROP_TIME2 2 datetime Value to set/get second coordinate time part.
We’ve already given the answer. Use object trend
 
toksis:

Hello,

How do you do that using Object create?


thanks

Subject: Hline drawn from Time A to Time B.

As these pros pointed out, a particular object of a certain type may use either pixel coordinates or time/price.
Visually an object may be what your looking for but functionally it may not be. Hline uses price only 
 
As William and the other pros here pointed out, when studying the example shown for OBJ_TREND you can also see ObjectMove below and see how time,price is used and declared throughout the example. 

Now study Hline and there is no such time/price used. It may visually look like something you want but it may not be.
Trendline can be a Ray in both directions similar to Hline but uses 2 time and 2 price parameters or it can if you want to. 
 


This properties table shows more about this too. 
https://docs.mql4.com/constants/objectconstants/enum_object_property



Object Properties - Objects Constants - Constants, Enumerations and Structures - MQL4 Reference
Object Properties - Objects Constants - Constants, Enumerations and Structures - MQL4 Reference
  • docs.mql4.com
Object Properties - Objects Constants - Constants, Enumerations and Structures - MQL4 Reference