is there a bug in mt5 ObjectDelete?

 

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!

 

int ObjCount = ObjectsTotal(ChartID(),/*0=main subwindow*/0,/*all objectTypes*/-1);

bool deleteResult=ObjectDelete(ChartID(),"non existing object");

Print(__LINE__,"-",deleteResult," | ObjCount=",ObjCount); 

 

here is the result :

 2016.12.11 13:46:38.385 Far-Test (EURUSD,H1) 37-true | ObjCount=0

 

shouldn't it return false ?  


 
Farzin Sadeghi:

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!

 

int ObjCount = ObjectsTotal(ChartID(),/*0=main subwindow*/0,/*all objectTypes*/-1);

bool deleteResult=ObjectDelete(ChartID(),"non existing object");

Print(__LINE__,"-",deleteResult," | ObjCount=",ObjCount); 

 

here is the result :

 2016.12.11 13:46:38.385 Far-Test (EURUSD,H1) 37-true | ObjCount=0

 

shouldn't it return false ?  


here is the result of the same code in mt4 : 

2016.12.11 14:00:10.141 Far-TestObjDelete EURUSD_e,H1: 38-false | ObjCount=0

 so mt5 is working wrong ! 

 
Farzin Sadeghi:

here is the result of the same code in mt4 : 

2016.12.11 14:00:10.141 Far-TestObjDelete EURUSD_e,H1: 38-false | ObjCount=0

 so mt5 is working wrong ! 

What build of MT5 are you using? The current available build is 1495 (09 Dec 2016)!
 
Fernando Carreiro:
What build of MT5 are you using? The current available build is 1495 (09 Dec 2016)!
yes , the mt5 is build 1495 , 2016.dec.09 ,  and metaeditor is 1495 too.
 
Farzin Sadeghi:
yes , the mt5 is build 1495 , 2016.dec.09 ,  and metaeditor is 1495 too.

Please provide a complete small test script/indicator code that we can compile and test it on our end to see if it also produces the same effect?

If it does do the same on our end, then you can report it to the Service Desk as a possible bug!

Attach it as a complete file, in your next post!

 
Fernando Carreiro:

Please provide a complete small test script/indicator code that we can compile and test it on our end to see if it also produces the same effect?

If it does do the same on our end, then you can report it to the Service Desk as a possible bug!

Attach it as a complete file, in your next post!

here is the same code both in mt5 and mt4 . results are different but help file says the same.

 

ObjectDelete

The function removes the object with the specified name from the specified chart.

bool  ObjectDelete(
   long    chart_id,     // chart identifier
   string  name          // object name
   );

Parameters

chart_id

[in]  Chart identifier. 0 means the current chart.

name

[in]  Name of object to be deleted.

Return Value

Returns true if the removal was successful, otherwise returns false.

 
Farzin Sadeghi: here is the same code both in mt5 and mt4 . results are different but help file says the same.
In a followup, in order to make sure it was not a bug in the OP's source code, I recreated my own code and got the same effect with the following Indicator code, and I too did indeed get the same result as the OP:
#property strict
#property indicator_chart_window

int OnInit()
{
   return(INIT_SUCCEEDED);
}

int OnCalculate(const int rates_total, const int prev_calculated, const datetime &time[],
   const double &open[], const double &high[], const double &low[], const double &close[],
   const long &tick_volume[], const long &volume[], const int &spread[])
{
   static bool boolFirstTime = true;
  
   if( boolFirstTime )
   {
      boolFirstTime = false;
      bool boolDeleteResult = ObjectDelete( 0, "Non-existing Object" );
      Print("Result of Deleteing non-existing Chart Object: ", boolDeleteResult );
   }
  
   return(rates_total);
}
The output was as follows:
2016.12.11 11:12:29.999 TestObjectDelete (EURUSD.m,H4)  Result of Deleteing non-existing Chart Object: true
So, this does indeed look like a bug that needs to be reported to the Service Desk.
 
Fernando Carreiro:
In a followup, in order to make sure it was not a bug in the OP's source, I recreated my own code and got the same effect with the following Indicator code, and I too did indeed get the same result as the OP:
#property strict
#property indicator_chart_window

int OnInit()
{
   return(INIT_SUCCEEDED);
}

int OnCalculate(const int rates_total, const int prev_calculated, const datetime &time[],
   const double &open[], const double &high[], const double &low[], const double &close[],
   const long &tick_volume[], const long &volume[], const int &spread[])
{
   static bool boolFirstTime = true;
  
   if( boolFirstTime )
   {
      boolFirstTime = false;
      bool boolDeleteResult = ObjectDelete( 0, "Non-existing Object" );
      Print("Result of Deleteing non-existing Chart Object: ", boolDeleteResult );
   }
  
   return(rates_total);
}
The output was as follows:
2016.12.11 11:12:29.999 TestObjectDelete (EURUSD.m,H4)  Result of Deleteing non-existing Chart Object: true
So, this does indeed look like a bug that needs to be reported to the Service Desk.
thanks for your time :)
 
Farzin Sadeghi:
thanks for your time :)
Are you going to report it on the Service Desk?
 
Fernando Carreiro:
Are you going to report it on the Service Desk?
yes I am going to write it. I was waiting for your confirmation. thanks.
 
Farzin Sadeghi:
yes I am going to write it. I was waiting for your confirmation. thanks.
I will do so as well to help reinforce the issue!
Reason: