OrderSend Error 148 — How to Fix?

OrderSend Error 148 or ERR_TRADE_TOO_MANY_ORDERS is a frequently appearing MetaTrader 4 error message, especially if you are trading on some demo/real contest account. The error means that you are trying to place an order or open a position when the maximum number has already been reached. Some Forex brokers limit the number of simultaneously open orders and positions (this doesn't count the stop-loss and take-profit orders). When the maximum is reached and your MT4 expert advisor sends a new order request (pending or market) you will get an "OrderSend Error 148" message in the Experts log of your platform; the order won't be executed.

As an MQL4 coder, you should handle these situations properly as they obviously lead to the incorrect functioning of the EA. Your expert advisor should be checking the maximum allowed number of orders and avoid opening new ones if the maximum is reached. Alternatively, it can try closing previous orders if a new order is to be opened.

The number of currently active orders and opened positions should be checked with the OrdersTotal() function.

The MQL4 (and MQL5 too) function to check the maximum allowed number of orders is the following:

AccountInfoInteger(ACCOUNT_LIMIT_ORDERS)

If the returned value is zero, then there is no limit on maximum simultaneously opened orders or positions in this account.

You can use this simple demo script to print the value in your trading platform:

//+------------------------------------------------------------------+
//|                                                       Demo-1.mq4 |
//|                                                    EarnForex.com |
//|                                       https://www.earnforex.com/ |
//+------------------------------------------------------------------+
#property copyright "EarnForex.com"
#property link      "https://www.earnforex.com/"
#property version   "1.00"
#property strict

//+------------------------------------------------------------------+
//| Script program start function                                    |
//+------------------------------------------------------------------+
void OnStart()
{
   Print("Account limit orders: ", AccountInfoInteger(ACCOUNT_LIMIT_ORDERS));
}

After executing, this script produces the following output in the RoboForex live account:

Sample Account Limit Orders Output in MT4 Platform

Unfortunately, there is no easy way to fix OrderSend Error 148 if you are a trader who doesn't know how to code in MQL4. In this case, your solution could probably be to ask your Forex broker to increase the limit, but that is quite unlikely to happen. Of course, there is no point in doing this if your EA tends to open infinite number of orders. In that case, it is better to ask some coder (on our Forex Jobs forum section, for example) to fix the expert advisor.

If you have any thoughts, comments, or questions regarding MT4 OrderSend Error 148 and the ways to treat it, feel free to join our Forex forum for discussions with other traders and MQL4 developers.


If you want to get news of the most recent updates to our guides or anything else related to Forex trading, you can subscribe to our monthly newsletter.

© 2005–2021

EarnForex.com

Design — Mart Studio

Forex trading bears intrinsic risks of loss. You must understand that Forex trading, while potentially profitable, can make you lose your money. Never trade with the money that you cannot afford to lose! Trading with leverage can wipe your account even faster.

CFDs are leveraged products and as such loses may be more than the initial invested capital. Trading in CFDs carry a high level of risk thus may not be appropriate for all investors.