Download MetaTrader 5

A couple of questions

To add comments, please log in or register
Alexander Martinez
578
Alexander Martinez  

1. Is it possible to get an object's index value by not having to cycle through a for loop with ObjectsTotal()?

‌2. Is it possible to get the index value by shift of a Channel's OBJPROP_PRICE3? (i.e., the trendline in a channel that has a single anchor point)

whroeder1
17093
whroeder1  
  1. Why would you want the index, if you have the name? No functions (except ObjectName) use the index.
  2. Write a three line script and find out.
Alexander Martinez
578
Alexander Martinez  
whroeder1:
  1. Why would you want the index, if you have the name? No functions (except ObjectName) use the index.
  2. Write a three line script and find out.

1. Long story short, there's an instance where the name of the object would change, so I figured it'd be best to know the Index (w/o having to cycle through a for loop) and grab the name of the object using ObjectName(). But I think I'm better off re-writing the code where the object description changes.

‌2. I've already tried everything, to the best of my knowledge, to get the value by shift of OBJPRICE_3, including looking at the various functions in the help manual, so I'm going to say the answer is no.

honest_knave
Moderator
2342
honest_knave  
user3822:

1. Long story short, there's an instance where the name of the object would change, so I figured it'd be best to know the Index (w/o having to cycle through a for loop) and grab the name of the object using ObjectName(). But I think I'm better off re-writing the code where the object description changes.

‌2. I've already tried everything, to the best of my knowledge, to get the value by shift of OBJPRICE_3, including looking at the various functions in the help manual, so I'm going to say the answer is no.


I'd need to be at a terminal to check, but I'm fairly confident if you rename an object it will end up with a different index. Renaming an object essentially deletes the old one and creates a new one.
Alexander Martinez
578
Alexander Martinez  
honest_knave:

I'd need to be at a terminal to check, but I'm fairly confident if you rename an object it will end up with a different index. Renaming an object essentially deletes the old one and creates a new one.
Thanks for the info. Either way, it seems like bad practice to change the object name if I need to continue to reference the object afterwards.
To add comments, please log in or register