スポンサーリンク
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 requested trade. The MQL4 error name is ERR_NOT_ENOUGH_MONEY.
The lot size itself may be valid, but the account cannot support that position size under the current margin conditions. This commonly happens when the EA requests a large lot size, existing positions already use margin, or the tested symbol requires more margin than expected.
Quick answer:
OrderSend Error 134 is ERR_NOT_ENOUGH_MONEY. Validate the lot size first, then use
OrderSend Error 134 is ERR_NOT_ENOUGH_MONEY. Validate the lot size first, then use
AccountFreeMarginCheck() before OrderSend() to confirm that the account has enough free margin for the requested symbol, order type, and volume.What Does OrderSend Error 134 Mean?
- Error code: 134
- Error name: ERR_NOT_ENOUGH_MONEY
- Meaning: Not enough money
Error 134 means that MT4 or the trade server rejected the order because there was not enough available margin to support the requested position.
int ticket = OrderSend(
Symbol(),
OP_BUY,
Lots,
Ask,
Slippage,
StopLoss,
TakeProfit,
"buy order",
Magic,
0,
clrBlue
); Even when Lots satisfies the symbol’s minimum lot, lot step, and maximum lot rules, the order can still fail if the account does not have enough free margin.
Common Causes of OrderSend Error 134
| Cause | Example | Typical Fix |
|---|---|---|
| Requested lot size is too large for the account | An EA attempts to open 1.00 lot on an account that can support only a smaller position | Reduce the intended position size or skip the trade |
| Existing positions already use margin | Several trades are open before the EA sends another order | Check free margin immediately before each new entry |
| Automatic lot sizing produces a large volume | A risk calculation increases the lot size after balance or stop-loss changes | Validate both volume rules and available margin |
| Symbol margin requirements are higher than expected | Gold, indices, CFDs, or another instrument requires more margin than a typical FX pair | Check margin using the actual symbol being traded |
| Test conditions differ from the intended account | Strategy Tester uses a different deposit or leverage assumption | Review the Strategy Tester account conditions |
Check Account Free Margin
You can inspect the current account margin status with the standard MQL4 account functions.
Print("Balance=", AccountBalance());
Print("Equity=", AccountEquity());
Print("Margin=", AccountMargin());
Print("FreeMargin=", AccountFreeMargin());
Print("Leverage=", AccountLeverage()); The most important value for a new trade is AccountFreeMargin(), which shows the currently available free margin.
However, checking the current free-margin value alone does not tell you exactly whether a specific new order can be opened.
For that, AccountFreeMarginCheck() is more useful.
Key point:
Use
Use
AccountFreeMargin() to understand the current account state and AccountFreeMarginCheck() to test a specific symbol, Buy/Sell direction, and lot size before sending the order.Use AccountFreeMarginCheck Before OrderSend
AccountFreeMarginCheck() estimates the free margin that would remain after opening a specified trade.
double freeMarginAfterTrade =
AccountFreeMarginCheck(
Symbol(),
OP_BUY,
Lots
);If the requested trade cannot be supported, the function can indicate insufficient margin and Error 134 can be generated.
MQL4 Code Example: Check Margin Before Trading
The following helper function checks margin before the EA calls OrderSend().
//+------------------------------------------------------------------+
//| Check whether the account can support a new market order |
//+------------------------------------------------------------------+
bool HasEnoughMargin(string symbol,
int orderType,
double lots)
{
if(lots <= 0)
{
Print("HasEnoughMargin: invalid lot size: ", lots);
return false;
}
if(orderType != OP_BUY &&
orderType != OP_SELL)
{
Print("HasEnoughMargin: unsupported order type: ",
orderType);
return false;
}
ResetLastError();
double freeMarginAfterTrade =
AccountFreeMarginCheck(
symbol,
orderType,
lots
);
int err = GetLastError();
if(err == 134)
{
Print("Not enough money.",
" Lots=", lots,
" FreeMargin=", AccountFreeMargin(),
" FreeMarginAfterTrade=", freeMarginAfterTrade);
return false;
}
if(freeMarginAfterTrade <= 0)
{
Print("Insufficient free margin.",
" Lots=", lots,
" FreeMarginAfterTrade=", freeMarginAfterTrade);
return false;
}
return true;
}Usage example:
double lots = 0.10;
if(!HasEnoughMargin(
Symbol(),
OP_BUY,
lots))
{
Print("Trade skipped because margin is insufficient.");
return;
}
RefreshRates();
double price =
NormalizeDouble(Ask, Digits);
ResetLastError();
int ticket = OrderSend(
Symbol(),
OP_BUY,
lots,
price,
Slippage,
0,
0,
"buy order",
Magic,
0,
clrBlue
);
if(ticket < 0)
{
int err = GetLastError();
Print("OrderSend failed. Error=", err,
" Lots=", lots,
" FreeMargin=", AccountFreeMargin());
} Recommended behavior:
If the intended lot size cannot be opened, skipping the trade keeps the EA’s position-sizing logic explicit. Automatically changing the lot size should be done only when that behavior is part of the strategy design.
If the intended lot size cannot be opened, skipping the trade keeps the EA’s position-sizing logic explicit. Automatically changing the lot size should be done only when that behavior is part of the strategy design.
Validate the Lot Size Before Checking Margin
Before checking margin, first make sure that the requested trade volume itself is valid.
Check:
MODE_MINLOTMODE_LOTSTEPMODE_MAXLOT
For example, a lot size of 0.015 may already be invalid if the symbol accepts only 0.01 steps.
That is an Error 131 problem, not an Error 134 problem.
A practical order-validation sequence is:
- Calculate the intended lot size.
- Validate MINLOT, LOTSTEP, and MAXLOT.
- Check available margin with
AccountFreeMarginCheck(). - Refresh the market price.
- Send the order.
Error 131 and Error 134 Are Different
Both errors can appear when an EA uses an inappropriate position size, but they mean different things.
| Error | Meaning | Main Area to Check |
|---|---|---|
| 131 | Invalid trade volume | MINLOT, LOTSTEP, MAXLOT |
| 134 | Not enough money | Free margin available for the requested trade |
For example:
Broker lot step = 0.01
Requested lot = 0.015This is primarily a volume-rule problem and may result in Error 131.
On the other hand:
Broker lot step = 0.01
Requested lot = 5.00
Lot itself = valid
Free margin = insufficientThis is an Error 134 situation.
MODE_MARGINREQUIRED Can Be Used as a Reference
MQL4 also provides MODE_MARGINREQUIRED through MarketInfo().
double marginPerLot =
MarketInfo(
Symbol(),
MODE_MARGINREQUIRED
);
double estimatedMargin =
marginPerLot * Lots;
Print("MarginRequiredPerLot=", marginPerLot);
Print("EstimatedMargin=", estimatedMargin);This can be useful when inspecting the symbol’s margin conditions.
Use AccountFreeMarginCheck() for the actual pre-trade check:
Margin behavior can depend on the symbol, account type, trade direction, broker settings, and current account state.
Margin behavior can depend on the symbol, account type, trade direction, broker settings, and current account state.
MODE_MARGINREQUIRED is useful as a reference, while AccountFreeMarginCheck() is the more practical check before a specific trade request.Should the EA Automatically Reduce the Lot Size?
One possible response to insufficient margin is to reduce the lot size until the order becomes affordable. However, that behavior changes the position size selected by the original strategy.
For example, if a risk-management rule calculated:
Requested lot = 0.50and the EA silently changes it to:
Actual lot = 0.17the trade no longer follows the original sizing decision.
Do not silently change the strategy:
For a general-purpose EA, it is usually clearer to reject the entry when the intended lot cannot be supported. Automatic lot reduction is appropriate only when the EA specification explicitly defines that behavior.
For a general-purpose EA, it is usually clearer to reject the entry when the intended lot cannot be supported. Automatic lot reduction is appropriate only when the EA specification explicitly defines that behavior.
If automatic reduction is intentionally part of the strategy, validate the final lot again against:
MODE_MINLOTMODE_LOTSTEPMODE_MAXLOTAccountFreeMarginCheck()
Automatic Lot Calculations Can Cause Error 134
Risk-based lot sizing is one of the most common places where Error 134 appears.
For example:
double riskMoney =
AccountBalance() * RiskPercent / 100.0;
double lots =
riskMoney / lossPerLot;The mathematical result may be valid, but the resulting lot size can still require more margin than the account currently has available.
Therefore, a risk-based position-sizing process should normally perform two separate validations:
- Volume validation — is the lot valid for the symbol?
- Margin validation — can the account support that lot right now?
Useful rule:
Lot calculation decides the intended position size.
Lot calculation decides the intended position size.
AccountFreeMarginCheck() then decides whether that position can actually be opened under the current margin conditions.Existing Positions Can Reduce Available Margin
An EA may successfully open one trade and then receive Error 134 on the next entry even though the lot calculation has not changed.
This can happen because existing positions already consume account margin.
Print("Margin=", AccountMargin());
Print("FreeMargin=", AccountFreeMargin());
Print("OpenOrders=", OrdersTotal());This is especially important for strategies that can hold multiple positions, including:
- Grid EAs
- Martingale or position-increase strategies
- Multi-symbol EAs
- Strategies that allow simultaneous Buy and Sell positions
For these EAs, perform the margin check immediately before every new order instead of checking only when the EA starts.
Error 134 in MT4 Strategy Tester
OrderSend Error 134 can also occur during an MT4 Strategy Tester backtest.
The EA logic may be functioning correctly while the simulated account no longer has enough free margin for the requested trade.
Check:
- Initial deposit
- Account currency
- Leverage used by the test environment
- Fixed lot setting
- Automatic lot calculation
- Number of simultaneous positions
- Margin conditions of the tested symbol
Do not fix the problem only by increasing the test deposit:
A larger initial deposit can make Error 134 disappear without fixing the underlying position-sizing logic. First confirm whether the EA is requesting the intended lot size and whether it performs a margin check.
A larger initial deposit can make Error 134 disappear without fixing the underlying position-sizing logic. First confirm whether the EA is requesting the intended lot size and whether it performs a margin check.
How to Debug OrderSend Error 134
When Error 134 occurs, print the actual lot size and the account margin state immediately before the trade request.
double lots = Lots;
double freeMargin =
AccountFreeMargin();
double marginPerLot =
MarketInfo(
Symbol(),
MODE_MARGINREQUIRED
);
ResetLastError();
double freeMarginAfterTrade =
AccountFreeMarginCheck(
Symbol(),
OP_BUY,
lots
);
int marginCheckError =
GetLastError();
Print("Lots=", lots);
Print("Balance=", AccountBalance());
Print("Equity=", AccountEquity());
Print("Margin=", AccountMargin());
Print("FreeMargin=", freeMargin);
Print("Leverage=", AccountLeverage());
Print("MarginRequiredPerLot=", marginPerLot);
Print("FreeMarginAfterTrade=", freeMarginAfterTrade);
Print("MarginCheckError=", marginCheckError);A practical troubleshooting order is:
- Confirm that the actual error is 134.
- Print the lot size passed to
OrderSend(). - Confirm that the volume itself is valid.
- Print
AccountFreeMargin(). - Run
AccountFreeMarginCheck()with the exact order type and lot size. - Check whether existing positions are already using margin.
- Review any automatic position-sizing calculation.
- In Strategy Tester, review deposit and account conditions.
Error 129 vs 130 vs 131 vs 134
| Error | Meaning | Main Area to Check |
|---|---|---|
| 129 | Invalid price | Execution price |
| 130 | Invalid stops | SL, TP, pending-order distance |
| 131 | Invalid trade volume | Minimum lot, lot step, maximum lot |
| 134 | Not enough money | Available margin for the requested trade |
Related MQL4 OrderSend Guides
FAQ About OrderSend Error 134
Q. What does OrderSend Error 134 mean in MT4?
OrderSend Error 134 is ERR_NOT_ENOUGH_MONEY. It means that the account does not have enough free margin to support the requested trade.
Q. Why does Error 134 occur even when the lot size is valid?
A volume can satisfy MODE_MINLOT, MODE_LOTSTEP, and MODE_MAXLOT while still requiring more margin than the account currently has available. That is an Error 134 situation rather than Error 131.
Q. How do I check free margin in MQL4?
AccountFreeMargin() shows the current available free margin. For a specific potential order, AccountFreeMarginCheck() is more useful because it evaluates the requested symbol, order type, and lot size.
Q. Can automatic lot calculation cause Error 134?
Yes. A risk-based lot calculation can produce a structurally valid trade volume that still requires more margin than is currently available. Check margin after calculating and validating the lot size.
Q. Should an EA automatically reduce the lot size after Error 134?
Only if automatic reduction is part of the EA’s intended position-sizing rules. Otherwise, it is clearer to skip the trade because silently changing the lot size changes the strategy’s original sizing decision.
Q. Is Error 134 the same as Error 131?
No. Error 131 means the trade volume does not satisfy the symbol’s lot rules. Error 134 means the requested volume may be valid, but there is not enough available margin to open it.
Q. Can Error 134 occur in MT4 Strategy Tester?
Yes. It can occur when the simulated account cannot support the requested trade volume. Check the initial deposit, test account conditions, position size, and number of simultaneous positions.
Q. How do I fix OrderSend Error 134?
Validate the lot size, check AccountFreeMargin(), use AccountFreeMarginCheck() before OrderSend(), review existing margin usage, and confirm that the intended position size can be supported by the account. Reduce the lot only when that behavior matches the EA’s position-sizing rules.
Summary
OrderSend Error 134 in MT4/MQL4 is ERR_NOT_ENOUGH_MONEY. It means that the account cannot support the requested trade under the current margin conditions.
- Error 134 means Not Enough Money.
- Validate the lot size before performing the margin check.
- Use
AccountFreeMargin()to inspect the current account state. - Use
AccountFreeMarginCheck()before a specific trade request. MODE_MARGINREQUIREDcan be useful as a margin reference.- Existing positions can reduce the free margin available for new entries.
- Automatic position sizing should be checked for both valid volume and sufficient margin.
- Do not silently reduce the intended lot unless that behavior is part of the strategy.
- Error 131 concerns volume rules; Error 134 concerns margin availability.
