MQL4参考 检测 IsTradeAllowed

IsTradeAllowed

Checks if the Expert Advisor is allowed to trade and trading context is not busy.

bool  IsTradeAllowed();

The second form of the function checks trade status for the specified symbol in the specified time.

bool  IsTradeAllowed(
  const string symbol       // symbol
  datetime     tested_time  // time
   );

Parameters

symbol

[in]  Symbol.

tested_time

[in]  Time to check status.

Returned value

Returns true if the Expert Advisor is allowed to trade and trading context is not busy, otherwise returns false.

Note:

OrderSend(), OrderClose(), OrderCloseBy(), OrderModify(), OrderDelete() trading functions changing the state of a trading account can be called only if trading by Expert Advisors is allowed (the "Allow live trading" checkbox is enabled in the Expert Advisor or script properties).

Example:

  if(IsTradeAllowed()) Print("Trade allowed");

See also

IsDllsAllowed(), IsLibrariesAllowed(), IsTradeContextBusy()