MT4 error 4200: Object already exists (ERR_OBJECT_ALREADY_EXISTS)
ObjectCreate() was called with a name that is already on the chart. Check with ObjectFind() first, or move the existing object.
4200ERR_OBJECT_ALREADY_EXISTS
After a fixSafe to retry?
Not a tradeCould it have executed?
What it means
You see this code in GetLastError() in MQL4, raised inside the terminal.
Chart objects need unique names. Creating one with a name already in use fails with 4200.
It is not a trade error, but it is one of the most common errors in MT4 logs, because programs often redraw lines on every tick.
Common causes
ObjectCreate()on every tick with the same name.- Objects left on the chart from a previous run.
How to fix it
- Call
ObjectFind()first, and move the object withObjectMove()orObjectSet()if it exists. - Delete your objects in
OnDeinit().
Example in MQL4:
void DrawEntry(double entryPrice)
{
string name = "entry_line";
if(ObjectFind(0, name) < 0)
ObjectCreate(0, name, OBJ_HLINE, 0, 0, entryPrice); // first time only
else
ObjectMove(0, name, 0, 0, entryPrice); // later: move it
}
void OnDeinit(const int reason) { ObjectDelete(0, "entry_line"); } Is it safe to retry?
Not as a create. Move or delete the existing object.
Could the order have executed?
Not a trade code.
Related codes
One API for MT4 and MT5
Clear trade outcomes, idempotent orders and an audit log. Read the error reference or the quickstart.