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 !
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)!
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!
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( |
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.
The output was as follows:#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);
}
So, this does indeed look like a bug that needs to be reported to the Service Desk.2016.12.11 11:12:29.999 TestObjectDelete (EURUSD.m,H4) Result of Deleteing non-existing Chart Object: true
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:
The output was as follows:#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);
}
So, this does indeed look like a bug that needs to be reported to the Service Desk.2016.12.11 11:12:29.999 TestObjectDelete (EURUSD.m,H4) Result of Deleteing non-existing Chart Object: true
thanks for your time :)
Are you going to report it on the Service Desk?
yes I am going to write it. I was waiting for your confirmation. thanks.

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
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 ?