Blog / Fix MT5 errors · Trade errors · MQL5 · MQL4
Invalid Stops (Error 130 / 10016): Stop Level and Freeze Level Explained
Understand MT4 error 130 and MT5 error 10016, how stop and freeze levels work, and how to prevent invalid-stop errors in your EA.
· 10 min read
What Does Invalid Stops Mean in MT4 and MT5?
Invalid stops occur when an Expert Advisor (EA) submits Stop Loss, Take Profit or pending-order prices that violate the broker's trading restrictions.
The error appears under different codes:
- MT4 error 130 (
ERR_INVALID_STOPS): The submitted stop levels or pending-order prices are invalid. - MT5 error 10016 (
TRADE_RETCODE_INVALID_STOPS): The trade server rejected the request because its stop levels are invalid.
For example, an EA might submit a Buy position with a Stop Loss 10 points below the current Bid when the broker requires a minimum distance of 20 points.
The request may be rejected because the Stop Loss is too close to the market.
However, distance is not the only possible cause. Incorrect Bid/Ask references, invalid price increments and broker-specific restrictions can also trigger these errors.
Two symbol properties are particularly important when diagnosing the problem: stop level and freeze level.
Stop Level vs. Freeze Level: What's the Difference?
Both restrictions affect trade prices, but they serve different purposes.
1. Stop Level: Minimum Permitted Price Distance
The stop level defines the minimum distance, in points, between certain trade prices and the relevant current market price.
It affects:
- Stop Loss levels.
- Take Profit levels.
- Pending-order entry prices.
For example, if the broker specifies a stop level of 20 points, an affected price generally cannot be placed closer than 20 points to its applicable market reference.
The reference price depends on the operation:
- Buy position Stop Loss and Take Profit: measured against Bid.
- Sell position Stop Loss and Take Profit: measured against Ask.
- Buy pending-order entry prices: generally referenced to Ask.
- Sell pending-order entry prices: generally referenced to Bid.
If the EA uses the wrong reference price or ignores the minimum distance, the server may reject the request.
2. Freeze Level: Restricted Trading Operations Near the Market
The freeze level defines a price range around the current market within which certain operations on existing positions and pending orders may be restricted.
It commonly affects attempts to:
- Modify an existing position's Stop Loss or Take Profit.
- Change a pending order's entry price.
- Delete a pending order.
- Perform other restricted operations on an affected order or position.
For example, an EA may successfully open a position and later attempt to move its Stop Loss as the trade becomes profitable.
If the relevant price falls inside the broker's freeze zone, the modification may be rejected.
This is particularly important for trailing-stop systems and EAs that frequently modify pending orders.
Stop Level vs. Freeze Level
| Feature | Stop Level | Freeze Level |
|---|---|---|
| Main purpose | Defines minimum permitted price distances | Restricts certain operations near the market |
| Commonly affects | Stop Loss, Take Profit and pending-order prices | Modification, deletion and other restricted operations |
| MT4-related error | 130 — Invalid stops | 145 — Modification denied |
| MT5 return code | 10016 — Invalid stops | 10029 — Frozen |
MT4 error 145 (ERR_TRADE_MODIFY_DENIED) and MT5 return code 10029 (TRADE_RETCODE_FROZEN) are not the same as invalid-stops errors.
They indicate that a trade operation was restricted, often because the affected order or position was inside the broker's freeze zone.
What Causes Invalid Stops in an EA?
Knowing the broker's restrictions is only part of the diagnosis. The EA's own price calculations and order-management logic can also cause the problem.
1. Stop Loss or Take Profit Is Too Close to the Market
This is one of the most common causes.
Suppose EURUSD has a Bid price of 1.08500 and the broker specifies a minimum stop distance of 20 points.
On a five-digit EURUSD quote:
- 1 point = 0.00001.
- 20 points = 0.00020.
A Buy position's Stop Loss must therefore be at least 20 points below the applicable Bid price.
A Stop Loss at 1.08490 is only 10 points away, so the server may reject it.
The same principle applies to Take Profit and Sell positions, but the relevant reference price changes.
How to fix it: Retrieve the symbol's current stop level and validate the proposed price against the correct Bid or Ask before sending the request.
2. Using the Wrong Bid or Ask Price
Buy and Sell positions use different price references when validating protective levels.
| Position | Opening price | Stop Loss / Take Profit reference |
|---|---|---|
| Buy | Ask | Bid |
| Sell | Bid | Ask |
For example, an EA that calculates a Buy position's Stop Loss using Ask instead of Bid may underestimate the actual distance from the relevant market price.
This can cause the server to reject an otherwise reasonable-looking stop.
The problem is more likely in multi-symbol EAs that use the chart's Bid and Ask instead of retrieving current prices for the instrument being traded.
How to fix it: Retrieve the latest Bid and Ask for the actual trading symbol and use the correct reference for each operation.
3. Ignoring the Broker's Stop Level
Stop-distance requirements can differ between brokers and instruments.
An EA that uses a hardcoded 20-point stop distance may work on one symbol but fail on another.
Requirements can also change with broker configurations.
How to fix it: Retrieve SYMBOL_TRADE_STOPS_LEVEL in MQL5 or MODE_STOPLEVEL in MQL4 instead of assuming every instrument uses the same restriction.
4. Attempting to Modify an Order Inside the Freeze Level
An EA may open a position successfully but fail when it later tries to modify its Stop Loss or Take Profit.
This can happen when the market moves close to the existing protective level or pending-order entry price.
If the affected operation is inside the broker's freeze zone, repeatedly sending the same modification request will not solve the problem.
How to fix it: Check the freeze-level restriction before modifying or deleting an order. If the operation is restricted, log the condition and reassess when market conditions change.
5. Incorrect Price Normalization
Different Forex and CFD instruments use different price precision and minimum price increments.
For example, a five-digit EURUSD quote and a two-digit gold quote do not use the same decimal precision.
In MQL5, two properties matter:
SYMBOL_DIGITS: Number of decimal places used for the symbol's prices.SYMBOL_TRADE_TICK_SIZE: Minimum permitted price change.
NormalizeDouble() can adjust decimal precision, but it does not guarantee that a calculated price aligns with the instrument's tick size.
How to fix it: Retrieve the symbol's digits and tick size, align calculated prices to valid increments, and then format them to the required precision.
How to Check Stop Level and Freeze Level in MT5
MQL5 provides two symbol properties for retrieving these restrictions:
SYMBOL_TRADE_STOPS_LEVELSYMBOL_TRADE_FREEZE_LEVEL
Both values are expressed in points and can be retrieved using SymbolInfoInteger().
Use this function to inspect the current chart symbol:
void CheckSymbolLevels()
{
long stop_level = 0;
long freeze_level = 0;
if(!SymbolInfoInteger(_Symbol, SYMBOL_TRADE_STOPS_LEVEL, stop_level))
{
Print("Failed to retrieve stop level. Error: ", GetLastError());
return;
}
if(!SymbolInfoInteger(_Symbol, SYMBOL_TRADE_FREEZE_LEVEL, freeze_level))
{
Print("Failed to retrieve freeze level. Error: ", GetLastError());
return;
}
PrintFormat(
"Symbol: %s | Stop Level: %d points | Freeze Level: %d points",
_Symbol,
(int)stop_level,
(int)freeze_level
);
}The function retrieves both values and prints them in the Experts log.
For example, if the output shows a stop level of 20 and a freeze level of 10, the EA should account for both restrictions when preparing trade requests and managing existing orders.
Important: A zero stop-level value does not always mean that stops can be placed at any distance. Some brokers use floating or dynamic restrictions that are not fully represented by the value returned to the terminal. The server can still reject the request with error 10016.
How to Check Stop Level and Freeze Level in MT4
MQL4 provides similar functionality through MarketInfo().
The relevant identifiers are:
MODE_STOPLEVELMODE_FREEZELEVEL
Use the following function:
void CheckSymbolLevels()
{
double stop_level = MarketInfo(Symbol(), MODE_STOPLEVEL);
double freeze_level = MarketInfo(Symbol(), MODE_FREEZELEVEL);
PrintFormat(
"Symbol: %s | Stop Level: %.0f points | Freeze Level: %.0f points",
Symbol(),
stop_level,
freeze_level
);
}This retrieves the restrictions for the current chart symbol.
As in MT5, a zero stop-level value does not necessarily mean there are no restrictions. An MT4 broker may use a floating stop level that cannot be displayed through MODE_STOPLEVEL. Error 130 can still occur in that situation.
How to Fix Invalid Stops in MT4 and MT5
Once the EA has retrieved the relevant symbol specifications, correct the price calculations and order-management logic.
1. Calculate Stop Distances Using the Correct Price
For open market positions, validate protective levels against the appropriate closing-side price.
The basic relationships are:
Buy position
- Stop Loss must be below Bid.
- Take Profit must be above Bid.
Sell position
- Stop Loss must be above Ask.
- Take Profit must be below Ask.
The broker's minimum stop distance must also be satisfied.
For pending orders, validate the entry price against the appropriate reference for the order type. Buy pending-order prices are generally referenced to Ask, while Sell pending-order prices are generally referenced to Bid.
2. Retrieve Current Symbol Specifications
Avoid hardcoding stop and freeze levels.
Use:
- MQL5:
SymbolInfoInteger() - MQL4:
MarketInfo()
Retrieve the values for the actual symbol being traded. This allows the EA to adapt to different instruments and broker configurations.
For multi-symbol EAs, do not assume the chart symbol's specifications apply to every instrument.
3. Align Prices With the Symbol's Tick Size
In MQL5, retrieve the symbol's tick size and decimal precision:
double tick_size = SymbolInfoDouble(
_Symbol,
SYMBOL_TRADE_TICK_SIZE
);
long digits = SymbolInfoInteger(
_Symbol,
SYMBOL_DIGITS
);
if(tick_size <= 0)
{
Print("Invalid tick size for ", _Symbol);
return;
}
PrintFormat(
"Symbol: %s | Tick Size: %s | Digits: %d",
_Symbol,
DoubleToString(tick_size, (int)digits),
(int)digits
);The tick size defines the minimum permitted price increment. The digits property defines how many decimal places are used to represent the price.
A calculated Stop Loss, Take Profit or pending-order price must align with the tick size before being submitted.
Do not rely on NormalizeDouble() alone to make an invalid price tradable.
4. Check Freeze-Level Restrictions Before Modifying Orders
Before modifying or deleting a pending order, or changing protective levels, check whether the relevant operation is restricted by the broker's freeze level.
If it is restricted:
- Avoid repeatedly sending the same request.
- Log the affected symbol, order or position, and current market prices.
- Reassess the operation when market conditions change.
Do not automatically move Stop Loss levels farther away simply to bypass a restriction. Any adjustment must remain consistent with the strategy's risk rules.
5. Handle Dynamic Stop-Level Restrictions
If the broker reports a zero stop level but the server still rejects a request with error 130 or 10016, investigate whether dynamic restrictions are being applied.
Record the following information when a request fails:
- Submitted Stop Loss and Take Profit prices.
- Current Bid and Ask.
- Stop level and freeze level.
- Symbol digits and tick size.
- Server return code or terminal error.
A reasonable safety buffer may help account for small price movements between calculation and execution. However, it is not a guaranteed solution to dynamic broker restrictions.
How to Reproduce and Troubleshoot Invalid Stops
A controlled test on a demo account can help identify the conditions that trigger invalid-stops errors.
Follow these steps:
- Open a demo account with a broker that provides the instrument you want to test.
- Retrieve the instrument's stop and freeze levels.
- Create a test EA that submits a Stop Loss or pending-order price inside the reported minimum stop distance.
- Check the Experts and Journal logs for the server response.
- Repeat the test with a valid distance and compare the results.
- For freeze-level testing, open a position or place a pending order and attempt a modification while the relevant price is inside the freeze zone, where the broker's settings permit this test.
The objective is to understand how the broker handles these restrictions, not to repeatedly submit invalid requests on a live account.
A zero or dynamically controlled stop level may also produce different results from the displayed symbol specification.
How to Prevent Invalid Stops in Your EA
A reliable EA should validate trade prices before sending requests and handle rejected modifications properly.
Use these checks:
- Retrieve stop and freeze levels for the actual trading symbol.
- Use the correct Bid and Ask references for each operation.
- Validate Stop Loss, Take Profit and pending-order prices before submitting requests.
- Align calculated prices with the symbol's tick size.
- Avoid assuming that a zero stop level means there are no restrictions.
- Check freeze-level restrictions before modifying or deleting orders.
- Log rejected requests with their submitted prices and server return codes.
- Avoid endlessly retrying requests that violate broker restrictions.
These checks are particularly important for EAs that use trailing stops, dynamic Take Profit calculations or frequent pending-order modifications.
Can PositionAlpha Help Fix Invalid Stops in an EA?
If your EA repeatedly produces invalid-stop errors, the underlying issue may be in its price calculations, order-management functions or handling of broker-specific trading requirements.
With PositionAlpha's Fix an EA, you paste or upload the EA and describe the problem. The AI returns the complete updated .mq4 or .mq5 file and explains the problems it found and each change it made. Compile the result in MetaEditor and test it in the Strategy Tester and on a demo account before you rely on it.
Conclusion
MT4 error 130 and MT5 error 10016 indicate that a trade request contains invalid stop levels. The underlying cause may involve incorrect price calculations, broker-defined minimum distances, symbol specifications or dynamic restrictions.
Understanding the difference between stop level and freeze level is essential. Stop level defines minimum permitted distances for certain trade prices, while freeze level restricts specific operations near the current market price.
By retrieving symbol specifications, validating prices against the correct Bid or Ask, aligning prices with tick size and checking modification restrictions, developers can reduce invalid-stop errors and make their Expert Advisors more reliable.
Build a bot from your idea
Describe your trading idea and the AI writes MT4 or MT5 code for you to review and test, with a plain-English explanation and setup steps. Your first bot is free.