Advertisement
OrderSend Error 134 in MT4/MQL4: Not Enough Money Fix

OrderSend Error 134 in MT4/MQL4 means that the account does not have enough free margin to open the order. In most cases, this error occurs when the lot size is too large for the account balance, leverage, or margin requirement of the selected symbol.
This error is commonly shown as Not Enough Money. It does not usually mean that the entry signal itself is wrong. It means that the account cannot support the order size at the time the EA tries to open a trade.
Quick answer:
OrderSend Error 134 is ERR_NOT_ENOUGH_MONEY. Check the lot size, account free margin, leverage, and margin required for the symbol before calling
OrderSend Error 134 is ERR_NOT_ENOUGH_MONEY. Check the lot size, account free margin, leverage, and margin required for the symbol before calling
OrderSend().What Does OrderSend Error 134 Mean?
In MQL4, Error 134 is known as:
- Error code: 134
- Error name: ERR_NOT_ENOUGH_MONEY
- Meaning: Not enough money
This means that the order volume is valid, but the account does not have enough free margin to open the position.
OrderSend(Symbol(), OP_BUY, Lots, Ask, Slippage, StopLoss, TakeProfit, "buy order", Magic, 0, clrBlue); If Lots is too large for the account, MT4 may return Error 134 and the order will not be placed.
Common Causes of OrderSend Error 134
| Cause | Example | How to Fix |
|---|---|---|
| Lot size is too large | The EA tries to open 1.00 lot on a small account | Reduce the lot size or add a margin check before trading |
| Free margin is too low | Existing positions already use most of the margin | Check AccountFreeMargin() before opening a new order |
| Leverage is too low | The same lot size requires more margin on a low-leverage account | Reduce the lot size according to the account leverage |
| Symbol margin requirement is high | Gold, indices, CFDs, or exotic pairs may require more margin | Check the margin requirement for each symbol |
| Automatic lot calculation returns too large a lot | A risk-based lot function calculates a lot size that the account cannot support | Limit the calculated lot by free margin |
How to Check Free Margin in MQL4
The first step is to check the account’s free margin.
You can use AccountFreeMargin() to see how much margin is currently available.
double freeMargin = AccountFreeMargin();
Print("Account balance: ", AccountBalance());
Print("Account equity: ", AccountEquity());
Print("Account margin: ", AccountMargin());
Print("Account free margin: ", freeMargin);
Print("Account leverage: ", AccountLeverage());If free margin is already low, even a small order may fail with Error 134. This is especially common when the account already has open positions.
Important:
Error 134 is not the same as Error 131. Error 131 means the lot size is invalid. Error 134 means the lot size may be valid, but the account does not have enough margin to open the trade.
Error 134 is not the same as Error 131. Error 131 means the lot size is invalid. Error 134 means the lot size may be valid, but the account does not have enough margin to open the trade.
How to Estimate Required Margin
You can estimate the required margin for the selected symbol by using MODE_MARGINREQUIRED.
double marginRequiredPerLot = MarketInfo(Symbol(), MODE_MARGINREQUIRED);
double estimatedMargin = marginRequiredPerLot * Lots;
Print("Margin required per 1 lot: ", marginRequiredPerLot);
Print("Lots: ", Lots);
Print("Estimated required margin: ", estimatedMargin);
Print("Free margin: ", AccountFreeMargin()); If estimatedMargin is larger than the current free margin, the order is likely to fail.
Note:
Margin calculation can differ by broker, symbol, account type, and leverage. Use this as an estimate, and confirm the actual result with
Margin calculation can differ by broker, symbol, account type, and leverage. Use this as an estimate, and confirm the actual result with
AccountFreeMarginCheck().MQL4 Code Example: Check Margin Before OrderSend
The safest approach is to check whether the account has enough margin before calling OrderSend().
//+------------------------------------------------------------------+
//| Check whether there is enough free margin before opening an order |
//+------------------------------------------------------------------+
bool HasEnoughMargin(string symbol, int orderType, double lots)
{
ResetLastError();
double freeMarginAfterTrade = AccountFreeMarginCheck(symbol, orderType, lots);
int err = GetLastError();
if(err == 134)
{
Print("Not enough money. Error 134.");
return false;
}
if(freeMarginAfterTrade <= 0)
{
Print("Free margin after trade is too low: ", freeMarginAfterTrade);
return false;
}
return true;
}You can use this function before sending an order.
RefreshRates();
double lots = 0.10;
if(!HasEnoughMargin(Symbol(), OP_BUY, lots))
{
Print("Order skipped because there is not enough margin.");
return;
}
int ticket = OrderSend(
Symbol(),
OP_BUY,
lots,
Ask,
Slippage,
0,
0,
"buy order",
Magic,
0,
clrBlue
);
if(ticket < 0)
{
int err = GetLastError();
Print("OrderSend failed. Error: ", err);
}This prevents the EA from repeatedly sending orders that cannot be opened because of insufficient margin.
Reduce Lot Size Automatically When Margin Is Not Enough
If your EA calculates the lot size automatically, you may need to reduce the lot size when the account does not have enough free margin.
The example below reduces the lot size step by step until the margin check passes.
//+------------------------------------------------------------------+
//| Get lot digits from lot step |
//+------------------------------------------------------------------+
int LotDigitsByStep(double lotStep)
{
int digits = 0;
while(lotStep < 1.0 && digits < 8)
{
lotStep *= 10.0;
digits++;
}
return digits;
}
//+------------------------------------------------------------------+
//| Reduce lot size until enough margin is available |
//+------------------------------------------------------------------+
double AdjustLotByMargin(string symbol, int orderType, double lots)
{
double minLot = MarketInfo(symbol, MODE_MINLOT);
double lotStep = MarketInfo(symbol, MODE_LOTSTEP);
double maxLot = MarketInfo(symbol, MODE_MAXLOT);
if(lotStep <= 0)
lotStep = 0.01;
if(lots > maxLot)
lots = maxLot;
lots = MathFloor((lots + 0.00000001) / lotStep) * lotStep;
lots = NormalizeDouble(lots, LotDigitsByStep(lotStep));
while(lots >= minLot)
{
ResetLastError();
double freeMarginAfterTrade = AccountFreeMarginCheck(symbol, orderType, lots);
int err = GetLastError();
if(err != 134 && freeMarginAfterTrade > 0)
return lots;
lots -= lotStep;
lots = NormalizeDouble(lots, LotDigitsByStep(lotStep));
}
return 0;
}Usage example:
RefreshRates();
double requestedLots = 1.00;
double lots = AdjustLotByMargin(Symbol(), OP_BUY, requestedLots);
if(lots <= 0)
{
Print("No valid lot size can be opened with the current free margin.");
return;
}
int ticket = OrderSend(
Symbol(),
OP_BUY,
lots,
Ask,
Slippage,
0,
0,
"buy order",
Magic,
0,
clrBlue
);
if(ticket < 0)
{
Print("OrderSend failed. Error: ", GetLastError());
}This kind of check is useful for EAs that use automatic lot calculation, martingale logic, grid trading, or multiple positions.
Strategy Tester and Error 134
OrderSend Error 134 can also occur in the MT4 Strategy Tester. This often happens when the initial deposit, leverage, lot size, or symbol settings do not match the EA’s assumptions.
For example, an EA may work on a live account but fail in the Strategy Tester if the test deposit is too small or the leverage setting is different.
When Error 134 occurs during backtesting, check the following:
- Initial deposit amount
- Account currency used in the test
- Leverage setting
- Fixed lot value in the EA inputs
- Risk-based lot calculation result
- Number of open positions
- Margin requirement of the tested symbol
Note:
If an EA uses a fixed lot that is too large, increasing the test deposit may hide the error. The safer solution is to add a margin check and limit the lot size inside the EA.
If an EA uses a fixed lot that is too large, increasing the test deposit may hide the error. The safer solution is to add a margin check and limit the lot size inside the EA.
How to Debug OrderSend Error 134
When Error 134 occurs, print the lot size, margin information, and account status. This makes it much easier to identify why the order failed.
double marginRequiredPerLot = MarketInfo(Symbol(), MODE_MARGINREQUIRED);
double estimatedMargin = marginRequiredPerLot * Lots;
Print("Lots: ", Lots);
Print("Balance: ", AccountBalance());
Print("Equity: ", AccountEquity());
Print("Margin: ", AccountMargin());
Print("Free margin: ", AccountFreeMargin());
Print("Leverage: ", AccountLeverage());
Print("Margin required per 1 lot: ", marginRequiredPerLot);
Print("Estimated required margin: ", estimatedMargin);Then check the Experts tab or the Journal tab in MT4. If the required margin is larger than the available free margin, that is likely the reason for Error 134.
Error 134 vs Error 131
Error 134 is often confused with Error 131 because both can be related to lot size. However, the meaning is different.
| Error | Meaning | Main Cause |
|---|---|---|
| Error 131 | Invalid trade volume | The lot size does not match the broker’s lot rules |
| Error 134 | Not enough money | The account does not have enough free margin |
If the lot size is below the minimum lot or does not match the lot step, check Error 131. If the lot size is valid but the account cannot support the trade, check Error 134.
Related MQL4 Errors
OrderSend Error 134 is one of several common OrderSend errors in MT4. The table below shows related errors that are often checked together.
| Error Code | Error Name | Main Cause |
|---|---|---|
| 129 | ERR_INVALID_PRICE | The order price is invalid |
| 130 | ERR_INVALID_STOPS | Stop loss, take profit, or pending order price is invalid |
| 131 | ERR_INVALID_TRADE_VOLUME | The lot size is invalid |
| 134 | ERR_NOT_ENOUGH_MONEY | The account does not have enough free margin |
FAQ About OrderSend Error 134
What does OrderSend Error 134 mean in MT4?
OrderSend Error 134 means ERR_NOT_ENOUGH_MONEY. It occurs when the account does not have enough free margin to open the order.
Why does Error 134 occur even when the lot size is valid?
A lot size can be valid according to the broker’s lot rules but still require more margin than the account has available. In that case, MT4 may return Error 134.
How can I check free margin in MQL4?
You can check free margin by using AccountFreeMargin(). You can also use AccountFreeMarginCheck() to estimate whether a new order can be opened with a specific lot size.
Can automatic lot calculation cause Error 134?
Yes. A risk-based lot calculation may return a lot size that is too large for the account’s free margin. The calculated lot should be checked against margin requirements before calling OrderSend().
Is Error 134 the same as Error 131?
No. Error 131 means invalid trade volume, while Error 134 means not enough money. Error 131 is about broker lot rules, and Error 134 is about margin availability.
How do I fix OrderSend Error 134?
Reduce the lot size, check account free margin, review leverage and margin requirements, and add AccountFreeMarginCheck() before OrderSend() to prevent orders that cannot be opened.
Summary
OrderSend Error 134 in MT4/MQL4 means that the account does not have enough free margin to open the order. In most cases, the lot size is too large for the account balance, leverage, or symbol margin requirement.
- Error 134 is ERR_NOT_ENOUGH_MONEY.
- Check
AccountFreeMargin()before opening a new order. - Use
AccountFreeMarginCheck()to confirm whether the account can support the lot size. - Check
MODE_MARGINREQUIREDto estimate required margin. - Reduce the lot size if the account does not have enough free margin.
- If the lot size itself is invalid, check OrderSend Error 131 instead.
If your EA returns Error 134, start by printing the lot size, account free margin, leverage, and estimated required margin. Understanding the margin condition is the fastest way to fix the EA and avoid repeated order failures.
Related: OrderSend Error 129 in MT4/MQL4
Related: OrderSend Error 130 in MT4/MQL4
