Negative Lock in Forex and How to Get Out of It: Methods and VR Unlock Smart
Hello, friends! My name is Vladimir. I am a trader and a developer of trading robots for MetaTrader 4 and MetaTrader 5, and I have been doing this for more than 20 years. Today we will talk about a situation that sooner or later happens to many traders who use locking: the negative lock. We will look at what it is, how it appears, which ways out exist, and what is good or risky about each of them. In a separate block I will describe VR Unlock Smart, a utility I created specifically for gradually unlocking negative locks.
A few links to make things easier for you:
- I invite you to become my friend on MQL5 so you do not miss new articles: my profile.
- My other articles: "How to Become a Successful Trader" and "Trading Strategy with Positive Locks", as well as the full list of my blog posts.
- My products on MQL5: seller page.
- Telegram channel: t.me/tgforexen.
- Demo versions of my products on Trading-Go: trading-go.net.
What is a lock in trading
A lock, or locking, is a situation where BUY and SELL positions of equal volume are open on the same instrument at the same time. In MetaTrader 5 this requires a hedging account type; in MetaTrader 4 it is usually available by default, but it is always worth checking your broker's conditions. While both positions are open, the profit of one offsets the loss of the other, and the combined result stops depending on price movement: it becomes frozen. That is where the name comes from: the positions are locked together.
Traders use locks for different reasons: to stop a loss from growing without closing the position emotionally, to wait out a news release, to keep the main position during a sharp move, or simply to buy time until the direction of the market becomes clearer. A lock is neither good nor bad by itself, it is a tool. Everything depends on whether the trader has a thought-out plan for how to unlick it later.
Positive and negative locks: what is the difference
Everything is determined by the relative position of the opening prices. If SELL is opened above BUY with equal lots, the lock is positive: while the positions are open, the combined result is fixed and above zero. I described such locks in detail in my article about the VR Locker robot. If BUY is opened above SELL, the lock is negative: the combined result is also constant, but it is below zero.
Let us take a simple example. A BUY of 0.10 lot on EURUSD is opened at 1.1000, and a SELL of 0.10 lot at 1.0950. The distance between the opening prices is 50 pips, or 0.0050. For 0.10 lot one pip is worth about 1 dollar. At any current price BUY gives (price − 1.1000), SELL gives (1.0950 − price), and the sum is always −0.0050, or roughly −50 dollars before swaps, spread and commissions. If the price rises, the profit on BUY grows and the loss on SELL grows by the same amount; if it falls, the opposite happens. The sum stays the same.
In reality a negative lock is almost never a single pair of positions. Most often it is a whole basket of dozens of BUY and SELL trades with different opening prices and different volumes. The total volume of buys may equal the total volume of sells, or it may differ. The more trades there are and the wider the price spread, the harder it is to see by eye what to do with it all.
How a trader ends up in a negative lock
There are several paths to this situation, and these are the three most typical:
- A lock instead of a stop loss. The position went against the teader, and he opened an opposite one of the same volume. The loss stopped growing, but nobody closed anything: "I will wait, maybe it will come back".
- A grid or averaging against the trend. A robot or a trader accumulated a series of positions in one direction, the price kept moving against them, and opposite positions were opened to stop the drawdown.
- An emotional decision. A sharp move after news, panic, a quick opposite position, and now there are two baskets on the account and no plan.
I have noticed that all these stories have one thing in common: the lock was opened as a temporary measure, and there was no plan for getting out of it. BUY and SELL positions keep hanging, the price goes up and down, and the loss does not go anywhere.
What is really hidden behind a "frozen" loss
It seems that since the result no longer changes, you can calmly wait. In practice a lock has several hidden costs worth knowing about:
- Swap. It is charged or credited every night for each open position. In a large basket these amounts become noticeable over time.
- Margin. Brokers calculate margin for opposite positions differently: some charge reduced margin, others the full amount. Check your broker's conditions, because the load on your account depends on it.
- Commissions and spread. Every action inside a lock (closing, opening new positions) has its price.
- Psychology. A lock removes pressure in the moment but postpones the decision. The longer it hangs, the harder it is to part with it.
- The illusion of safety. The loss does not grow, but it does not shrink by itself either. To close the basket you still have to make a decision about both sides, not just one.
The main ways out of a negative lock
There is no universal "unlock" button. Each approach has strengths and limitations, and the choice depends on the size of the basket, free margin and your readiness to accept a loss. Let us go through the main options.
1. Close everything and fix the loss
The simplest path: close all positions and accept the result. The advantage is that margin is freed immediately, swaps stop and you no longer have to watch the basket. The limitation is obvious: the loss becomes real in full, and psychologically this is the hardest step. In practice it works like this: this option makes sense when the cost of holding the lock (swap, margin load, attention) exceeds the reasonable chances of unlocking it calmly.
2. Close one side of the lock
The classic method: wait for a strong move in one direction and close the positions of the side that went into profit. The remaining positions wait for the price to return. The advantage is a quick reduction of volume and realized profit on one side. The limitation is that it is always a forecast. If the price reverses, the remaining side keeps losing without the protection of opposite positions, and the loss grows. This is the most emotionally loaded variant, because you have to choose the moment yourself.
3. Unlocking by combinations of opposite positions
Instead of closing a whole side, you can look for groups of BUY and SELL positions whose combined result is positive and close only those. The basket becomes smaller, part of the margin is released, and no new positions are opened. The limitation: combinations depend on the opening prices and the current price. If there are no suitable groups, you have to wait for the market to move. Going through dozens of positions by hand is also tiring, and it is easy to make a mistake in the calculation.
4. Averaging
The idea is to open an additional position in the direction of the price so that the basket's breakeven price moves closer to the market. The breakeven price of a group of positions is a weighted average: the sum of "price × lot" divided by the sum of lots. The advantage is that a smaller price return is enough to exit. The limitations are growing volume and margin load, and if the market keeps moving against the added position, the loss grows faster. Averaging always requires a reserve of free funds, and a good averahe plan should be written down in advance.
5. Partial closing with minimum lots
Positions can be closed not entirely but in parts, for example 0.01 lot from each of several old trades. The benefit is that the basket can be reduced gradually and you do not have to wait for the price to return to the opening levels of all positions at once. The limitations: much depends on the broker's minimum lot step and the number of trades, and doing this by hand is routine, attentive work that is better automated.
6. Working with free margin
Every unlocking method relies on free funds: without a margin reserve you can neither average nor sit through a drawdown. Adding funds to the account gives more free margin, but it does not reduce the loss by itself, and it should only be done with money whose loss you are ready to accept. I do not advise topping up an account "for the lock" without a calculation and without understanding how exactly you will unlock the basket.
An example with numbers: how the approaches differ
Let us take our lock: BUY 0.10 lot at 1.1000 and SELL 0.10 lot at 1.0950. The price has fallen to 1.0900. The floating result on BUY is about −100 dollars, on SELL about +50 dollars, the sum is −50 dollars. Let us see what happens with different decisions. The figures are illustrative and do not include swap, spread or commissions.
| Approach | Action | Breakeven price | Comment |
| Close everything | Close BUY and SELL | — | Fix −50 $, no positions left |
| Close SELL | Realize +50 $ on SELL, BUY 0.10 at 1.1000 remains | 1.0950 | 50 pips from the current 1.0900 to breakeven |
| Close SELL and average | Close SELL, open BUY 0.10 at 1.0900 | 1.0925 | 25 pips to breakeven, but the BUY volume is twice as large |
You can see that averaging moved the exit price 25 pips closer, but the price paid was a doubled volume: each pip against the positions now costs twice as much. That is why I treat averaging as a tool to be used with a margin reserve and clear limits.
Where to start when analyzing a lock
Before closing or opening anything, I recommend running a short review of the situation:
- Calculate the total BUY and SELL volumes and the average price of each side separately.
- Estimate the total floating result and the distance from the current price to the breakeven price.
- Check free margin and the margin level on the account.
- Estimate the accumulated swap of the basket and how fast it grows.
- Find positive combinations of opposite positions that can be closed without new trades.
- Decide in advance under what conditions you will stop and close the whole basket.
When there are dozens of positions, such a review in a spreadsheet takes a lot of time, and a mistake in one number can spoil the whole decision. That is the task I built a separate tool for.
VR Unlock Smart: unlocking negative locks
VR Unlock Smart is a trading robot utility for MetaTrader 5 that helps to unlock negative locks gradually. It is distributed for free, and the product page is here: VR Unlock Smart MT5. There is a separate version for MetaTrader 4: VR Unlock Smart. When creating it, I relied on ideas from two of my own advisors: from VR Smart Grid I took the principles of averaging, average price calculation and partial closing of positions, and the experience of VR Locker helped with managing opposite BUY and SELL positions. The main idea is not to fight the whole lock at once but to take it apart in small groups of positions, using market movement to reduce the accumulated loss.
How the robot unlocks a lock
The algorithm works in cycles, and each cycle consists of several steps:
- Position analysis. The advisor counts BUY and SELL positions, their volumes, opening prices, current result, and the average prices of buys and sells. Based on this data it decides which positions to work with first.
- Closing profitable combinations. Before using averaging, the robot looks for combinations of opposite positions whose joint closing gives a positive result. If there are any, the basket is reduced without opening additional trades.
- Averaging the remaining positions. When no suitable combinations remain, the averaging algorithm is switched on: when a set distance is reached, an additional BUY or SELL position is opened, which brings the calculated exit price of the selected group closer to the market. The location and volumes of already open positions are taken into account.
- Partial closing. When the price reaches the closing conditions of the selected group, the basket is reduced by partially closing positions with the minimum allowed lot and by closing separate large positions. For example, instead of fully closing several old trades, 0.01 lot can be closed from each of them.
- Repeating cycles. After each closing, the robot analyzes the remainder again. Even if all SELL positions are already closed and only BUY remain (or vice versa), the algorithm provides for further management of a one-sided bsaket.
- Freeing the account. The final goal is to close all positions of the managed basket. If market conditions allow the remaining groups to be closed one after another, the work continues until the number of open positions reaches zero.
Strategy tester, demo account and real account
So that you can check the algorithm without opening dozens of positions manually, in the strategy tester the advisor builds a lock by itself from many BUY and SELL trades with equal total volumes and then starts unlocking it. The volume of the test lock is set in the settings. In visual mode you can watch how the robot analyzes positions, adds averaging trades and closes combinations. On a demo account the principle is the same: the advisor creates a lock and works with it on the current market, with no risk to real funds.
On a real account the task is different: the robot manages already existing positions and does not create a new lock. The number and volumes of buys and sells may differ: the advisor is designed both for fully locked baskets and for baskets where one side prevails.
How to test it properly
- In the MetaTrader 5 strategy tester (Ctrl+R) choose the advisor, instrument, period, deposit and leverage as close as possible to your real conditions.
- For the most accurate check use the "Every tick based on real ticks" mode and enable visualization.
- Be sure to choose the hedging account type (Hedging), otherwise holding BUY and SELL on one instrument at the same time is impossible.
- When the algorithm successfully completes a full cycle and closes all positions, a vertical line appears on the tester chart.
- Check different market periods: growth, decline, sideways movement, high volatility, as well as different deposits and lock volumes. Look not only at closed trades but also at Equity, free margin, the number of positions and drawdown.
- Then run a demo account of the broker you plan to trade with and watch the work when the spread widens and margin is short.
- Create several baskets on the demo: an equal lock, a lock with unequal volumes, a basket of only BUY and a basket of only SELL.
Important warnings
- The account must have free funds and sufficient margin: for averaging the advisor can open additional positions. A lack of margin can interfere with the algorithm and lead to forced closing of positions by the broker.
- There is no guarantee of successfully unlocking a lock. The result depends on the state of the account, the location of positions, available funds and further market movement.
- Averaging carries additional risk.
- A good tester result does not mean the robot will unlock any real lock: history does not reproduce all features of real execution.
- First of all, the advisor tries to release available funds: if the account has positive locks or profitable combinations, it closes them first.
Recommendations
I recommend treating a lock as a temporary measure that must have an exit plan from the very beginning. Here is what turns out to be most important in practice:
- I recommend writing down, before opening a lock, under what conditions and in what way you will unlock it.
- Do not use a lock as a replacement for a stop loss if you are not ready to keep working with it: it only freezes the loss.
- Watch margin and accumulated swap: they most often determine how much time you have.
- In practice it works like this: first profitable combinations of opposite positions are closed, then, with enough margin, averaging is applied, and the remaining basket is reduced by partial closings.
- I have noticed that traders more often fail not in choosing the unlocking method but in lacking a margin reserve and patience.
- Test any method, including VR Unlock Smart, in the tester and on a demo account of the broker you are going to trade with.
- Do not use funds you cannot afford to lose to unlock a lock. Sometimes consciously closing the whole basket is also a reasoned decision.
If this material was useful, join the Telegram channel and visit my MQL5 profile, where I share new articles and breakdowns. Trading on financial markets involves a risk of losing funds, and this material is educational and is not a trading recommendation.


