Forex Blog

First-hand Forex trading experience and information about foreign exchange market that will be useful to traders


OrderSend Error 134 (No Enough Money)

November 12, 2010 (Last updated on December 15, 2016) by

Sometimes, especially during backtesting or in case of a badly designed expert advisor, the OrderSend Error 134 (or ERR_NOT_ENOUGH_MONEY) appears in the Journal log of your MetaTrader platform. In MT5 this error is called TRADE_RETCODE_NO_MONEY and has a code 10019. The reason for this error is the same for both versions of the platform — lack of free margin to execute the OrderSend function for the given position volume. The methods to solve this error are quite different (we won’t discuss the post-development method, which is to deposit more funds to your trading account).

In MetaTrader 4, you have to code your EA to perform the following check before executing OrderSend():

if (AccountFreeMarginCheck(Symbol(), Direction, Volume) > 0)

It will check how much free margin will be available after opening a position with the volume = Volume in a given direction = Direction. But comparing it with 0 isn’t a very good solution. One should pay attention to the broker’s stop-out level to consider the margin requirements:

if (((AccountStopoutMode() == 1) && 
(AccountFreeMarginCheck(Symbol(), Direction, Volume) > AccountStopoutLevel()))
|| ((AccountStopoutMode() == 0) && 
((AccountEquity() / (AccountEquity() - AccountFreeMarginCheck(Symbol(), Direction, Volume)) * 100) > AccountStopoutLevel())))

This way we check the way your broker applies stop-out (absolute or relative level) and check if we’ll have enough margin after our next trade.

For MetaTrader 5 this condition would look like this (replace SYMBOL_MARGIN_LONG with SYMBOL_MARGIN_SHORT if you want to check margin before opening a short position):

&& (AccountInfoDouble(ACCOUNT_FREEMARGIN) - SymbolInfoDouble(Symbol(), SYMBOL_MARGIN_INITIAL) * Lots * SymbolInfoDouble(Symbol(), SYMBOL_MARGIN_LONG) > AccountInfoDouble(ACCOUNT_MARGIN_SO_SO)))
&& ((AccountInfoDouble(ACCOUNT_EQUITY)/(AccountInfoDouble(ACCOUNT_EQUITY) - (AccountInfoDouble(ACCOUNT_FREEMARGIN) - SymbolInfoDouble(Symbol(), SYMBOL_MARGIN_INITIAL) * Lots * SymbolInfoDouble(Symbol(), SYMBOL_MARGIN_LONG))) * 100 > AccountInfoDouble(ACCOUNT_MARGIN_SO_SO))))

It is quite complex compared to the MT4 version but it checks the same condition.

Registering with a Forex broker that offers a lower stop-out level is also a good option :-).

Update 2016-11-01: Thanks to Alexander Wait’s comment, I have corrected the formulas for account margin check.

If you have any thoughts, comments, or questions regarding MetaTrader OrderSend Error 134 or Return Code 10019 in MT5 and the ways to treat it, feel free to reply to this post using the form below.

6 Responses to “OrderSend Error 134 (No Enough Money)”

  1. PipMaster

    thanks for this. i’ll note it and add it to my mt5 updates. with the error codes i mean.


  2. Wynne

    Nice tip. Ever since US broker decreased their leverage level, my EAs run into error 134 occasionally… Never tried programming for MT5, hope it won’t be too different… Thanks anyway


  3. Alexander Wait

    Great advice on how to fix error 134. I just wanted to point out that the

    following formula for MT4 is actually not quite right.

    Let X = AccountFreeMarginCheck(Symbol(), Direction, Volume); then

    (X / AccountEquity()) * 100) > AccountStopoutLevel() is incorrect.

    The correct formula is actually the following:

    (AccountEquity() / (AccountMargin()) * 100 > AccountStopoutLevel()

    Since AccountMargin() = AccountEquity() – X, the following formula is

    expressed in terms of free margin in the trading account:

    (AccountEquity() / (AccountEquity() – X)) * 100 > AccountStopoutLevel()


    Andriy Moraru Reply:

    Thanks a lot, Alexander! You are completely right! I have now updated the post to list the correct formula.


  4. darren

    Hi Guys im a newbie wanted to know what would be the setting for 30$ deposit to trade

    Kindly advise



    Andriy Moraru Reply:

    Your position size is limited depending on your broker’s required margin level.


Leave a Reply

required (will not be published)