How to use ObjectGetValueByShift("Horizontal Line", 0);

 

HI, I need your help.


I draw the horizontal Line on the chart by manual.

And I want the EA to read the value (price)

But when I draw it by manual, object name has some numbers. --> 38987

What is this number?

TO read the price of the line, I want to use

  double Price =ObjectGetValueByShift("Horizontal Line", 0);

But can I use wildcart of the object?

Instead of below?

  double dn=ObjectGetValueByShift("Horizontal Line 38987", 0);
 
Cromo:

HI, I need your help.


I draw the horizontal Line on the chart by manual.

And I want the EA to read the value (price)

But when I draw it by manual, object name has some numbers. --> 38987

What is this number?

TO read the price of the line, I want to use

But can I use wildcart of the object?

Instead of below?

When you draw the line, open the properties box and rename it.

You don't use 

double dn=ObjectGetValueByShift("Horizontal Line 38987", 0);

for a horizontal line as it only has 1 price.

Use ObjectGetDouble()

 

Thanks, Keith

is there any ways to pick up the price of the Horizontal line without rename it?

Like.... Find the pre-fix of Horizontal ****, then use ObjectGetDouble to read the price.

 
Cromo:

Thanks, Keith

is there any ways to pick up the price of the Horizontal line without rename it?

Like.... Find the pre-fix of Horizontal ****, then use ObjectGetDouble to read the price.

Loop through all objects on the chart and compare the name with pattern (using StringFind or StringSubstr).

See example from the ObjectsTotal help page

ObjectsTotal - Object Functions - MQL4 Reference
ObjectsTotal - Object Functions - MQL4 Reference
  • docs.mql4.com
When this function is used on the current chart, this chart is accessed directly, while in order to receive the properties of an object on a different chart, a synchronous call is used. The synchronous...
 
Cromo:

Thanks, Keith

is there any ways to pick up the price of the Horizontal line without rename it?

Like.... Find the pre-fix of Horizontal ****, then use ObjectGetDouble to read the price.

Only if you know for sure that there will only be 1 horizontal line on the chart at any time.

 
Keith Watford:

Only if you know for sure that there will only be 1 horizontal line on the chart at any time.

Thanks. I will try some other ways!
 
Drazen Penic:

Loop through all objects on the chart and compare the name with pattern (using StringFind or StringSubstr).

See example from the ObjectsTotal help page

Good idea... Nice! StringFind or StringSubstr
 
Cromo #:
Good idea... Nice! StringFind or StringSubstr

hi Cromo, do you manage to get over with this wildcard thing? i'm trying to solve the same issue of object_name+randomnumber (trying to get only the object_name without random number)  

Reason: