ObjectGetValueByShift does not work with horizontal lines?

 

I am trying to get the value (price for last bar) of a horizontal line (added manually to a graph) by the function ObjectGetValueByShift( after renaming it from object properties as "MyLine)"  ,  but the value returned is always zero.

The same function works correctly with a trendline added manually to the graph and renamed with same name "MyLine").

The code I am using for the EA  is  :

double price=ObjectGetValueByShift("MyLine", 0);

Any explanation for this weird behaviour ?

 

Why would you need to get the value by shift?

It is a horizontal line, there is only 1 price value 

  double price=ObjectGetDouble(0,"MyLine",OBJPROP_PRICE);

 .

 
GumRai:

Why would you need to get the value by shift?

It is a horizontal line, there is only 1 price value 

 .

I see, great !   With your code the call now works smoothly.

Thank you a lot GumRai


Regards

Max

Reason: