![MQL5 - Language of trade strategies built-in the MetaTrader 5 client terminal](https://c.mql5.com/i/registerlandings/logo-2.png)
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
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.
yes I am going to write it. I was waiting for your confirmation. thanks.
Just tried to report it on the Service Desk and it is not accepting my message, saying "Error saving data".
Tried it also from a different location, PC and browser (using my VPS) and the same happened.
Were you able to report it on your end?
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.
If that is the case, then the functionality difference between MQL4 and MQL5 is not reported or explained in the documentation!
Agreed. I'm just curious which one "they" will say is correct :-)
Personally, I think it is better to return true. Otherwise, you need to add extra code to check the object exists else put up with 4202 errors.
Agreed. I'm just curious which one "they" will say is correct :-)
Personally, I think it is better to return true. Otherwise, you need to add extra code to check the object exists else put up with 4202 errors.
In my opinion, in both cases one needs to check for the existence of the object before deleting, irrespective of which version is "correct".
EDIT: However, I hope they "fix" it so that it will work in the same manner as MQL4. Otherwise there will be yet another difference in functionality in which we will need to place conditional compilation in code made to compile on both versions.
In my opinion, in both cases one needs to check for the existence of the object before deleting, irrespective of which version is "correct".
Interesting! Why would you need to check it exists if you want it gone?
The time taken to check if a non-existent object exists is largely comparable to attempting to delete a non-existent object on MT4 (and a cursory inspection on MT5 shows it is substantially slower), so I can't see any tangible performance benefit by running the check. But it will add more lines to your code.
EDIT: However, I hope they "fix" it so that it will work in the same manner as MQL4. Otherwise there will be yet another difference in functionality in which we will need to place conditional compilation in code made to compile on both versions.
Interesting! Why would you need to check it exists if you want it gone?
The time taken to check if a non-existent object exists is largely comparable to attempting to delete a non-existent object on MT4 (and a cursory inspection on MT5 shows it is substantially slower), so I can't see any tangible performance benefit by running the check. But it will add more lines to your code.
When you want to detect if the user accidentally deleted it and needs to be recreated. I meant this as general "housekeeping" and not for a single once only delete functionality.
But yes, I agree, for a "OnDeinit()" functionality, there is no need to test it first.
When you want to detect if the user accidentally deleted it and needs to be recreated. I meant this as general "housekeeping" and not for a single once only delete functionality.
But yes, I agree, for a "OnDeinit()" functionality, there is no need to test it first.
Ah I see.
As a side note:
void OnStart()
{
string name = "MysteryObject";
ulong begin;
begin = GetMicrosecondCount();
for(int i=0; i<1000; i++) int result = ObjectFind(0,name);
printf("ObjectFind took %i μs", GetMicrosecondCount()-begin);
begin = GetMicrosecondCount();
for(int i=0; i<1000; i++) bool result = ObjectDelete(0,name);
printf("ObjectDelete took %i μs", GetMicrosecondCount()-begin);
}
Running it on MT4, there is not much in it.
Running it on MT5, it is over 50 times slower.
Does anyone have any insight into why?
As a side note:
Running it on MT4, there is not much in it.
Running it on MT5, it is over 50 times slower.
Does anyone have any insight into why?