MT4 code change to MT5 code

 

Hello, i have a code that use in MT4 which can alert the order send error.

But how can i change to MT5? Please help, Thanks

int OrderErrorReport (int OrderID)
{
   if (OrderID < 0)
      {
         Alert("Order rejected, please check error code: " + GetLastError());
      }

   else
      {
         Print("Order placed successful");
      }
      
      return OrderID;
}

Above code is using in MT4, i want to change it to MT5.

 

Read the help: Basic Principles

Scheme of trade operations: from order creation to execution by broker

and

Successful completion of the Buy(...) or Sell() method does not always mean successful execution of the trade operation. It is necessary to check the result of trade request (trade server return code) using ResultRetcode() and value returned by ResultDeal().
Basic Principles - Trading Operations - MetaTrader 5 Help
Basic Principles - Trading Operations - MetaTrader 5 Help
  • www.metatrader5.com
is an instruction given to a broker to buy or sell a financial instrument. There are two main types of orders: Market and Pending. In addition, there are special Take Profit and Stop Loss levels. is the commercial exchange (buying or selling) of a financial security. Buying is executed at the demand price (Ask), and Sell is performed at the...
Reason: