MQL4 ERR_NOT_ENOUGH_MONEY
MQL4 error 134 not enough money: causes and fixes
MQL4 error 134 not enough money maps to ERR_NOT_ENOUGH_MONEY: not enough money. The server rejected the trade because the account did not have enough free margin for the requested symbol, volume, and order type. For API calls, check the return value and capture GetLastError after a documented failure. Critical runtime errors require preventive guards and inspection of the terminal log.
Open the Coding Agent, then choose MQL4 from the language menu.
OrderSendMarginDiagnostic.mq4MQL4
#property strict
#property script_show_inputs
input double Lots = 0.10;
input int Slippage = 3;
void OnStart()
{
if(!IsTradeAllowed())
{
Print("Trading is not currently allowed or the trade context is busy.");
return;
}
RefreshRates();
double price = NormalizeDouble(Ask, Digits);
ResetLastError();
int ticket = OrderSend(Symbol(), OP_BUY, Lots, price, Slippage,
0, 0, "diagnostic", 0, 0, clrNONE);
if(ticket >= 0)
{
Print("Order opened. Ticket ", ticket);
return;
}
int error_code = GetLastError();
Print("OrderSend failed. error=", error_code,
" symbol=", Symbol(), " lots=", DoubleToString(Lots, 2),
" ask=", DoubleToString(price, Digits));
}