
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
Which build did you use? Since there seems to be a possible bug in the latest build with the "ObjectDelete()" function, it could be there is are also problems with the "ObjectFind()" as well!
MT5: Build 1495 (09 Dec 2016)
MT5: Build 1495 (09 Dec 2016)
I ran your code on build 1491 and got similar results:
I ran your code on build 1491 and got similar results:
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[4950],low[4980]);
Print(__LINE__,"-moveResult=",moveResult);
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.
Read Object Functions description
It means that command "Delete this object " successfully accepted. You can control the result of your command by GetLastError(). Try it - whic code is retutned?I changed the code this way :
int ObjCount = ObjectsTotal(ChartID(),/*0=main subwindow*/0,/*all objectTypes*/-1);
ResetLastError();
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
ERR_SUCCESS
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.
ERR_SUCCESS
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:
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:
How it could return false in this case ?
ObjectDelete() documentation says :
Return Value
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.
How it could return false in this case ?
ObjectDelete() documentation says :
The documentation should be clearer, it doesn't say "true if the command is accepted".
Wiil be fixed in such way
Return Value
Returns true if the command is placed in the common queue of the chart events, otherwise returns false.