ObjectGet error

 
Hi!

What is problem with this code?The line draw is good,but i would get XDISTANCE while i would make a label to this line,And i must know the "a" line coordinate.

ObjectCreate("a",OBJ_HLINE,0,0,price);
ObjectSet("a",OBJPROP_COLOR,Red);
ObjectSet("a",OBJPROP_WIDTH,1);

int XDISTANCE=ObjectGet("a", OBJPROP_XDISTANCE);
Print("Xdistance:",XDISTANCE);
And i get: "0"
Thanks for help!
 

Horizontal line has no X, Y or corner.

Those values applie to OBJ_LABEL only.

 
phy:

Horizontal line has no X, Y or corner.

Those values applie to OBJ_LABEL only.

Thanks!
And I how can i make,giving labels to line?
 

ObjectSetText("a", "SOME TEXT");

and on chart properties, "Show Object Descriptions"

That's one way.

Another is to create OBJ_TEXT

It has Price and Time coordinates.

 
phy:

ObjectSetText("a", "SOME TEXT");

and on chart properties, "Show Object Descriptions"

That's one way.

Another is to create OBJ_TEXT

It has Price and Time coordinates.

It's works! Thanks You!!
 
Phy:


Can you help me,what is wrong in this code?
The first method that you wrote me working great (ObjectSetText("a", "SOME TEXT");and on chart properties, "Show Object Descriptions")

But when I Create OBJ_TEXT don't work for me

Here is the wrong code
ObjectCreate("alabel",OBJ_TEXT,0,0,PRICE);
ObjectSetText("alabel", "Here is Label");


Thanks for your help!
Reason: