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.

11 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.


  5. Mandrake

    Hi, thanks for this thread and post.

    I have been doing a lot of back testing on my MT4 before now, it’s been going great (as supposed). But lately, it just stopped working totally and I mean all the expert advisors stopped placing trades (doesn’t matter what I do).

    I checked the journal section and found loads of OrderSend Error 134 and sometimes OrderSend Error 131. Got any idea on how to work around it?

    PS: I didn’t code any of the EAs, I believe however that all of the coders couldn’t have made the same mistake. My first suspect is my MT4 App but, let’s hear y’all smart minds thought on this..


    Andriy Moraru Reply:

    OrderSend Error 134 is an error that pops up when you don’t have enough money (margin) in your account to open a trade. Either you already have too many trades open or the EA is trying to open a trade that is too big for your account. This could also be caused by the broker’s increase in margin requirements.

    OrderSend Error 131 is an error that pops up when an EA is trying to open a trade with an incorrect volume. For example, if the minimum trade size is 0.1 and the EA is trying to send an order with 0.08 volume, it will be rejected with the Error 131. This could happen if your broker increased minimum trade volume or volume step either for your account type or for that particular instrument you are trying to trade.


  6. Thomas Bernard

    Hello, As said in the article I added the lines of code in my program however they tell me that I did not define the Symbol, Volume, and Direction functions.
    How should I define them?

    Thanks you from France


    Andriy Moraru Reply:

    Symbol() shouldn’t cause any problems – just make sure you are not skipping the brackets.

    Volume and Direction need to be replaced with your variables or direct values (e.g., 0.1 and OP_BUY if you want to test margin for going long 0.1 lot of the pair in MT4).


  7. Thomas Bernard

Leave a Reply

required (will not be published)