Use ObjectName with ChartID, it will work.
eddie:
I already tried replacing ObjectName(x) with ObjectName(ID,x) in the three lines that used it, it did not work. Well, it retrieved the object name, but the ObjectType function did not work, it returned -1 for all objects on charts where indicator was not loaded. It returned correct values for the chart the indicator was loaded on. Code does not compile when you try to put ChartID in ObjectType parameter list.
Use ObjectName with ChartID, it will work.
If you got the name you call ObjectGetInteger to get the Type.
eddie:
If you got the name you call ObjectGetInteger to get the Type.
OK, thanks. The following works:
if ((ObjectGetInteger(ID,ObjectName(ID,x),OBJPROP_TYPE) == OBJ_HLINE) || (ObjectGetInteger(ID,ObjectName(ID,x),OBJPROP_TYPE) == OBJ_TREND)) {
The MQL4 Reference help file needs to be updated to show that you can use ID with ObjectName.
Daniel Lewis:
OK, thanks. The following works:
The MQL4 Reference help file needs to be updated to show that you can use ID with ObjectName.
thanks for sharing
hope that service desk report the same to update help file/s for MQL4
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
In MT4, is it possible to read through all open charts and count all the HLINE and TREND objects of a specific color? I have the following code and know that the statements after the "for" loop will not work because the ObjectName function does not have a ChartID parameter. I tried looking for something else that might work (e.g. ObjectGetString) but haven't found anything.