Broker API HubMenu

MQL5 OrderCheck()

functionOrderCheck()MQL5Sending orders

Checks whether there is enough money for a trade request without sending it, and writes what the account would look like into a result structure.

Risk warning: CFDs and spread bets are complex instruments and come with a high risk of losing money rapidly due to leverage. You can lose money on these products, and each provider publishes its own loss figure under FCA rules. You should consider whether you understand how they work and whether you can afford to take the high risk of losing your money. Automated and API trading can amplify losses through bugs, connectivity failures and runaway orders.

Independent and unofficialmql5.comchecked

This is an MQL5 function, not an HTTP endpoint. It has no method, no path and no address to send a request to: it runs inside the MetaTrader 5 terminal, in a program written in MQL5.

Signature

The form of the call on the vendor's page, with the vendor's comments taken out.

bool OrderCheck(
  MqlTradeRequest& request,
  MqlTradeCheckResult& result
)

Arguments

NameTypeDescription
requestrequiredMqlTradeRequest&The trade request to check, an MqlTradeRequest structure passed by reference.
resultrequiredMqlTradeCheckResult&An MqlTradeCheckResult structure passed by reference, which receives the result of the check.

Return value

Type
bool
What comes back
False when funds are not enough or the request is filled in wrongly. True when the basic check of the structures passes, which the page says is still no promise that the trade would go through. On failure the page points to GetLastError() for the reason.

Sample

Written by this site from the signature and arguments recorded on this page. It has not been run against a terminal, a server or an account, and the values in it are placeholders. It holds no credential and needs none: the program runs inside a terminal that is already logged in to an account. Nothing is entered on this site.

void OnStart()
  {
   MqlTradeRequest     request={};
   MqlTradeCheckResult check={};
   request.action=TRADE_ACTION_DEAL;
   request.symbol=_Symbol;
   request.volume=0.1;
   request.type  =ORDER_TYPE_BUY;
   request.price =SymbolInfoDouble(_Symbol,SYMBOL_ASK);
   // Nothing is sent to the trade server by this call.
   if(!OrderCheck(request,check))
      PrintFormat("OrderCheck error %d, retcode=%u, %s",GetLastError(),check.retcode,check.comment);
   else
      PrintFormat("margin=%.2f free margin=%.2f",check.margin,check.margin_free);
  }

Return codes documented for this function

The page's example prints check.retcode as the server retcode, with outputs such as 10027 and 10018. Those are trade server return codes, and each one recorded here is below. mql5.comchecked