MT5 error 4751: Wrong trade property identifier (ERR_TRADE_WRONG_PROPERTY)

A trade property function was asked for a property id that doesn't exist or doesn't fit, such as a deal property on an order.

4751ERR_TRADE_WRONG_PROPERTY
After a fixSafe to retry?
Not a tradeCould it have executed?

What it means

You see this code in GetLastError() in MQL5, after a function fails.

Functions like OrderGetInteger, PositionGetDouble or HistoryDealGetString take a property id. 4751 means the id you passed doesn't belong to that function.

It is a coding mistake, not a trading condition.

Common causes

  • A DEAL_* id passed to an order function, or a POSITION_* id to a deal function.
  • An integer property asked for with the double function, or the reverse.
  • A cast that turned an enum into the wrong value.

How to fix it

  • Match the prefix to the function: ORDER_* with OrderGet*, POSITION_* with PositionGet*, DEAL_* with HistoryDealGet*.
  • Match the type too: integer, double or string.

Example in MQL5:

if(PositionSelectByTicket(ticket))
{
   double  sl    = PositionGetDouble(POSITION_SL);        // double property
   long    magic = PositionGetInteger(POSITION_MAGIC);    // integer property
   string  sym   = PositionGetString(POSITION_SYMBOL);    // string property
   // PositionGetDouble(DEAL_PROFIT) would fail: wrong family of ids.
}

Is it safe to retry?

After you correct the code.

Could the order have executed?

Not a trade code. Reading a property doesn't change the account.

All MetaTrader error codes

One API for MT4 and MT5

Clear trade outcomes, idempotent orders and an audit log. Read the error reference or the quickstart.