Download MetaTrader 5

Why won't this if statement recognize Left Price Labels?

To add comments, please log in or register
Alexander Martinez
162
Alexander Martinez  
Hi everyone,

I wrote an if statement to recognize left price labels, but for some reason, it doesn't recognize that the object is a Left Price Label.
if (ObjectType(ObjectName(x)) == OBJ_ARROW_LEFT_PRICE){

}
I have that if statement working with OBJ_HLINE, OBJ_CHANNEL, and OBJ_TRENDLINE, but can't get it to work with OBJ_ARROW_LEFT_PRICE.

Thanks for the help.
Carl Schreiber
7674
Carl Schreiber  
May be because x is incorrect?
Alexander Martinez
162
Alexander Martinez  
Carl Schreiber:
May be because x is incorrect?
x is an integer that represents the index number of the current object. x is obtained by running a for statement of every object on the current chart using ObjectsTotal(). Also, I'm testing this with only one object on the chart. Apologies for not clarifying that.


Like I mentioned, I have it working with OBJ_HLINE, OBJ_TREND, and OBJ_CHANNEL. Those get recognized perfectly by the if statement. Maybe there's something different about OBJ_ARROW_LEFT_PRICE?
whroeder1
16563
whroeder1  
Print out your variables, and find out why.
honest_knave
Moderator
2293
honest_knave  
ObjectType() of OBJ_ARROW_LEFT_PRICE will come up as OBJ_ARROW
Alexander Martinez
162
Alexander Martinez  
whroeder1:
Print out your variables, and find out why.
Thanks. Turns out, it's recognized as an ObjectType() of 22 (OBJ_ARROW_THUMB_DOWN).
honest_knave:
ObjectType() of OBJ_ARROW_LEFT_PRICE will come up as OBJ_ARROW
Even though my testing said it's OBJ_ARROW_THUMB_DOWN, this is pretty much what's happening.

I'm not sure why it's like that, but I'm guessing the workaround is check the arrow code for the arrow type I'm looking for.
honest_knave
Moderator
2293
honest_knave  
user3822:
Thanks. Turns out, it's recognized as an ObjectType() of 22 (OBJ_ARROW_THUMB_DOWN).Even though my testing said it's OBJ_ARROW_THUMB_DOWN, this is pretty much what's happening.

I'm not sure why it's like that, but I'm guessing the workaround is check the arrow code for the arrow type I'm looking for.

22 is OBJ_ARROW 

You just found another example of a "sub-object arrow type" (for want of a better phrase)

   ENUM_OBJECT object_type = 22;
   printf("ObjectType %i is %s", object_type, EnumToString(object_type));

 2017.02.15 15:10:45.186 Test Ger30Sb317,M1: ObjectType 22 is OBJ_ARROW


Alexander Martinez
162
Alexander Martinez  
honest_knave:

22 is OBJ_ARROW 

You just found another example of a "sub-object arrow type" (for want of a better phrase)

   ENUM_OBJECT object_type = 22;
   printf("ObjectType %i is %s", object_type, EnumToString(object_type));

 2017.02.15 15:10:45.186 Test Ger30Sb317,M1: ObjectType 22 is OBJ_ARROW


So all arrows fall under OBJ_ARROW object type?
whroeder1
16563
whroeder1  
user3822: So all arrows fall under OBJ_ARROW object type?
Apparently. Thumb down, left price or a wingding value is the arrow's property arrow code. arrow is the object's type.
Alexander Martinez
162
Alexander Martinez  
whroeder1:
Apparently. Thumb down, left price or a wingding value is the arrow's property arrow code. arrow is the object's type.
Gotcha. So it looks like I'll be checking the arrow's arrow code if I want to be able to identify a specific arrow. Thanks for the help, everyone!
To add comments, please log in or register