MT5: Build 1495 (09 Dec 2016)
I ran your code on build 1491 and got similar results:
2016.12.11 12:31:05.739 test (EURUSD.m,H1) ObjectFind took 20126 μs2016.12.11 12:31:05.739 test (EURUSD.m,H1) ObjectDelete took 247 μs
This could be semantic rather than a bug.
The purpose of ObjectDelete is to "remove the object with the specified name".
At the end of running the function, is there an object called "Non-existing Object" still on the chart? No... so is this success?
Looking at it another way, did ObjectDelete remove an object called "Non-existing Object"? No... so is this failure?
Do you measure success by the outcome or the action taken?
Perhaps a false would be expected if the named object remains on the chart after running the function. Otherwise, it was a success.
Maybe what you say is true but as we are migrating from MQL4 to MQL5 we are expecting to see the same result or at least a result that is clearly written in return value of the reference.
passing this first problem , I tested the ObjectMove function , and again I am getting TRUE result too! this moves beyond your explanation that because the object is not available in the end so the true is correct.
with ObjectMove on an object that is not available it should return false!
moveResult=ObjectMove(ChartID(),"not available trend line",1,time,low);
2016.12.11 17:22:39.367 Far-Test-ChangeTrendLine (EURUSD,H1) 44-moveResult=true
hi , I am writing an indicator in MQL5, but whatever I write as string name ObejectDelete returns true ! even on an empty chart with no objects!
Read Object Functions description
This is the group of functions intended for working with graphic objects relating to any specified chart.
The functions defining the properties of graphical objects, as well as ObjectCreate() and ObjectMove()
operations for creating and moving objects along the chart are actually
used for sending commands to the chart. If these functions are executed
successfully, the command is included in the common queue of the chart
events. Visual changes in the properties of graphical objects are
implemented when handling the queue of the chart events.
I changed the code this way :
int ObjCount = ObjectsTotal(ChartID(),/*0=main subwindow*/0,/*all objectTypes*/-1);
bool deleteResult=ObjectDelete(ChartID(),"non existing object");
Print(__LINE__,"-",deleteResult," | ObjCount=",ObjCount," | LastError=",GetLastError());
here is the result :
2016.12.12 12:38:43.373 Far-TestObjectDelete (EURUSD,H1) 38-true | ObjCount=0 | LastError=0
The operation completed successfully
so it does not return error to find out for example it couldn't access that object. but in MT4 it does return the error.
OK. As I found out we do not raise any error in such case in MQL5 because these operations are asynchronous. So you have 2 options:
OK. As I found out we do not raise any error in such case in MQL5 because these operations are anisochronous. So you have 2 options:
How it could return false in this case ?
ObjectDelete() documentation says :
Returns true if the removal was successful, otherwise returns false.
The documentation should be clearer, it doesn't say "true if the command is accepted".
If we want to be sure an object is delete, we will have to check if it exists after the delete command, it's non sense.
Wiil be fixed in such way