is there a bug in mt5 ObjectDelete? - page 2

 

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.

 
Farzin Sadeghi:
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?

 
honest_knave:

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!
 
Fernando Carreiro:
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.

 
honest_knave:

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.

 
Fernando Carreiro:
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.

 
Fernando Carreiro:

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.

Perhaps it is all part of their plan to force us to MT5 through frustration!
 
honest_knave:

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.

 
Fernando Carreiro:

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: 

#property strict

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? 

 
honest_knave: Ah I see.

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? 

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!