MQL4 Reference Account Information AccountFreeMarginCheck

MQL4 Help as One File:

AccountFreeMarginCheck

Returns free margin that remains after the specified order has been opened at the current price on the current account.

double  AccountFreeMarginCheck(
   string  symbol,     // symbol
   int     cmd,        // trade operation
   double  volume      // volume
   );

Parameters

symbol

[in]  Symbol for trading operation.

cmd

[in]  Operation type. It can be either OP_BUY or OP_SELL.

volume

[in]  Number of lots.

Returned value

Free margin that remains after the specified order has been opened at the current price on the current account. If the free margin is insufficient, an error 134 (ERR_NOT_ENOUGH_MONEY) will be generated.

Example:

  if(AccountFreeMarginCheck(Symbol(),OP_BUY,Lots)<=0 || GetLastError()==134) return;