Give this a try
The issue is that sparam (the object name) may be deleted before the second ObjectGetInteger call.
void OnChartEvent(const int id, const long &lparam, const double &dparam, const string &sparam) { if(id == CHARTEVENT_OBJECT_DELETE) { ENUM_OBJECT type = (ENUM_OBJECT)ObjectGetInteger(0, sparam, OBJPROP_TYPE); PrintFormat("%s: %d, %f, %s %s", EnumToString((ENUM_CHART_EVENT)id), lparam, dparam, sparam, EnumToString(type)); if(type == OBJ_TREND) { Print("DELETE ", sparam); } } }
OK, thanks. But it doesn't work, the rewritten code does not change the result.
This line will never be executed.
On the other side, you might be right, the object might have been deleted, so it is not possible to retrieve its property using ObjectGetInteger();
Let's consider this not a bug, but improper usage of deleted object.
Note to myself, never access deleted object.
This line will never be executed.
Print("DELETE ", sparam);
On the other side, you might be right, the object might have been deleted, so it is not possible to retrieve its property using ObjectGetInteger();
Let's consider this not a bug, but improper usage of deleted object.
Note to myself, never access deleted object.

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
Trying to delete object: OBJ_TREND
There is NO OBJ_VLINE on the chart !!!
I placed only this object on chart: