> For the complete documentation index, see [llms.txt](https://docs.metacopier.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.metacopier.io/features/basic-features/loss-protected-exit.md).

# Loss-Protected Exit

## Overview

**Loss-Protected Exit** is a copier-level safeguard for slave accounts. It protects slave positions in loss from being closed when the master closes them, for example after an accidental **"Close All"** on the master account. MetaCopier checks the current **net P\&L** of the corresponding slave position (floating profit including swap and commission). If the position is in loss, the close is **not** replicated and the position is **held** on the slave account. Optionally, the slave position's Take Profit is moved to the entry price (breakeven) so the position stays managed and eventually closes flat.

By default, only a **"Close All"** on the master is protected. A single close is replicated normally. You can also choose to protect **every** close in loss (see [Protection modes](#protection-modes)).

Close signals for positions that are at breakeven or in profit are always replicated immediately.

{% hint style="warning" %}
Enabling this feature means your slave accounts may keep positions open **after the master has flattened**. Held positions stay open until the breakeven Take Profit triggers, their Stop Loss is hit, or you close them manually. Make sure your strategy is compatible with carrying these residual positions.
{% endhint %}

{% hint style="info" %}
This feature is set on the **copier**, not on the master account. It only applies to slave-side execution and is available for **hedging accounts** only (see [Limitations](#limitations)).
{% endhint %}

## Why use it

Typical use cases:

* You copy a master that exposes a **"Close All"** button and want to protect slaves against an accidental click.
* You run **prop-firm slave accounts** where taking losses in bulk is unacceptable.
* You operate **large fleets of slave accounts** (hundreds or thousands) where a single master mistake would propagate at scale.
* Your trading rule is: *"never close a position while it is in negative P\&L."*

## How it works

1. When the master closes a position, MetaCopier locates the mirrored position on the slave account.
2. If other exit features delay the close (Exit Signal Override, Minimum Holding Time, Delayed Execution), they are applied first. The P\&L check happens at the moment the close would actually be executed.
3. MetaCopier reads the slave position's **net P\&L**: floating profit plus swap and commission. If the position is at breakeven, in profit, or within the configured tolerance, the close is replicated immediately.
4. If the loss is **strictly worse** than the tolerance, the [protection mode](#protection-modes) decides whether the close is protected. In **Close All only** mode, MetaCopier waits for the detection window to see whether the master is closing several positions at once.
5. If the close is protected, it is blocked and the position is **held**. Optionally, its Take Profit is set to the entry price (plus an optional offset to cover commission and swap).
6. The held position now runs on its own on the slave account. It closes once price reaches the breakeven Take Profit, when its Stop Loss is hit, or when you close it manually.

{% hint style="info" %}
**The decision is final.** Once a position is held, MetaCopier no longer closes it on behalf of the master, even if the position recovers before reaching the Take Profit. This also applies after a restart of the account.
{% endhint %}

### Protection modes

* **Close All only** (default): Protects slave positions only when the master closes **several positions at once**. A "Close All" does not close all positions at the same instant; the positions are closed one after another. When the master closes a position that is in loss on the slave account, MetaCopier waits for the **detection window** (default: 1 second):
  * If another position is closed on the master within that time, this is treated as a "Close All". All slave positions in loss from these closes are held. Closes of any position count here, including positions in profit.
  * If no other position is closed on the master, the close is replicated normally, just after the detection window.
* **Every close**: Every master close of a slave position in loss is blocked immediately, without a detection window. Use this if your rule is to never close a position in loss.

It does not matter how the master positions are closed: in the trading platform (for example MT5 or the broker's "Close All Positions" button) or through the MetaCopier API on the master account. Both are protected.

{% hint style="warning" %}
In **Close All only** mode, a "Close All" is detected by timing. If the master closes two positions within the detection window on purpose, or two Stop Losses on the master are hit at the same moment, this is also treated as a "Close All". If the master has only **one** position open and closes it, this cannot be told apart from a normal close, so that position is not protected.
{% endhint %}

### Partial closes

If the master **partially** closes a position while the slave position is in loss:

* In **Every close** mode, the partial close is held back. It is executed automatically as soon as the slave position is back within the tolerance. The Take Profit is not changed for partial closes, and the position keeps following the master.
* In **Close All only** mode, partial closes are replicated normally.

### Turning the feature off

Turning off Loss-Protected Exit (or a symbol override) does **not** close anything. Positions that are already held stay open with their Take Profit until it triggers, their Stop Loss is hit, or you close them manually. From then on, closes from the master are replicated normally again.

{% hint style="info" %}
Held positions can be identified in the positions API, so you can manage them with your own logic (for example, a trailing stop or a bulk close).
{% endhint %}

### Intentional closes in loss

MetaCopier cannot tell an accidental close from an intentional one. If the master deliberately closes several positions in loss at once (or, in **Every close** mode, a single position in loss), the slave positions are held as well. To exit such positions on the slave accounts, close them via the API. Closing a position **directly on the slave account** always works normally.

## Settings

* **Enabled**: Master toggle for the feature.
* **Protection mode**: `Close All only` (default) or `Every close`. See [Protection modes](#protection-modes).
* **Detection window (seconds)**: Only used in `Close All only` mode. How long MetaCopier waits for another master close before replicating a close in loss. Default: `1`. Increase it if the positions on your master are closed more slowly during a "Close All". Single closes in loss are delayed by this time.
* **Tolerance (% of balance)**: Net losses smaller than *this percentage of the slave account balance* are considered acceptable and the close is replicated normally. Percent is the recommended unit because it scales across accounts of any size. Set to `0` to disable the percent rule.
* **Tolerance (account currency)**: Net losses smaller than *this absolute amount in the account's currency* are considered acceptable and the close is replicated normally. Useful for prop-firm-style fixed rules. Set to `0` to disable the absolute rule.
* **Set TP at entry price (breakeven)**: When enabled, the slave position's Take Profit is moved to the entry price the moment a close is blocked. Recommended: **on**.
* **Overwrite existing TP**: Advanced. When enabled, the breakeven Take Profit replaces any existing Take Profit. When disabled, an existing Take Profit that is already at or better than breakeven is preserved.
* **Breakeven offset (points)**: Advanced. Points added on the favorable side of the entry price so the position truly closes flat after commission and swap. The breakeven Take Profit is a **price** breakeven, so without an offset the position closes at the entry price and costs are not covered.
* **Per-Symbol Configuration**: Different tolerance and breakeven values can be defined per symbol (using the slave account's symbol names). Symbol-specific rules always override the general settings. The protection mode and detection window apply to the whole copier.

{% hint style="info" %}
**Tolerance semantics:** If both tolerance fields are set, the **larger tolerance wins** (most permissive). If both are set to `0`, **any loss** is protected.
{% endhint %}

## Example use cases

1. **Protection against an accidental "Close All"**
   * Protection mode: `Close All only`
   * Detection window: `1` second
   * Tolerance (%): `0`
   * Tolerance (currency): `0`
   * Set TP at entry price: **on**
   * **Behavior:** If the master closes several positions at once, every slave position in loss is held and gets a breakeven Take Profit. Single closes on the master are replicated normally, with a delay of 1 second for positions in loss.
2. **Strict "never close in loss"**
   * Protection mode: `Every close`
   * Tolerance (%): `0`
   * Tolerance (currency): `0`
   * Set TP at entry price: **on**
   * **Behavior:** Any net loss blocks the master close. Every held position gets a breakeven Take Profit and closes flat when price returns.
3. **Small-spread tolerance across mixed account sizes**
   * Tolerance (%): `0.05` (0.05% of balance)
   * Tolerance (currency): `0`
   * Set TP at entry price: **on**
   * **Behavior:** Micro-losses caused by spread are ignored (close replicates normally). Larger losses are blocked and held. Scales cleanly from small to large slave accounts.
4. **Prop-firm fixed cap**
   * Tolerance (%): `0`
   * Tolerance (currency): `5` (5 USD)
   * Set TP at entry price: **on**
   * Breakeven offset (points): `10`
   * **Behavior:** Only net losses larger than 5 USD are protected. Held positions get a Take Profit 10 points beyond entry to cover commission and swap.
5. **Per-symbol override for volatile instruments**
   * Global: Tolerance (%) = `0.05`
   * XAUUSD override: Tolerance (%) = `0.2`
   * **Behavior:** Every symbol uses a tight 0.05% tolerance except gold, which gets a wider 0.2% cushion to absorb its larger spread.

## Interaction with other features

* **Max Open Positions**: Held positions still count against the limit. While they are held, new master trades may be skipped with `Open skipped (max open position)`. Copying resumes as soon as held positions close.
* **TP/SL Management with "Lock TP/SL"**: The close is still blocked, but the breakeven Take Profit is not set because TP/SL is locked. A warning is written to the account log.
* **Exit Signal Override, Minimum Holding Time, Delayed Execution**: Applied first. The P\&L is checked when the delay ends.
* **Stop Loss and account protections** (risk limits, profit targets, scheduled close, news protection, trading windows): Still apply and can close a held position, also in loss. Loss-Protected Exit only filters closes coming from the master.
* **Deleting the copier**: Held positions are not closed automatically, even when **Close unmanaged positions** is enabled on the account. They stay open until their Take Profit or Stop Loss triggers, or you close them manually.

## Limitations

* The feature acts on the **slave side only**. It cannot prevent the master broker from closing master-side positions.
* **Netting accounts and crypto exchanges are not supported.** On these accounts one slave position can combine several master positions, so a decision per master position is not possible. The feature has no effect there.
* On **pending orders** the feature has no effect: pending orders have no floating P\&L.
* In **Close All only** mode, positions closed on the master further apart than the detection window are treated as single closes. If the first close of a slow "Close All" arrives alone, it may still be replicated. Increase the detection window if needed.
* If the broker rejects the breakeven Take Profit (for example because price is very close to the entry price), the close stays blocked and MetaCopier retries setting the Take Profit periodically. A warning is written to the account log.
* When a connector does not support Take Profit modification, the close is still blocked but the breakeven Take Profit is not written. A warning is written to the account log.
* If the master flips a position (close and reverse) and Loss-Protected Exit blocks the close, the slave carries both the held position and the new reverse position as a hedged pair until the held position closes.

## Best practices

* Start on a **demo copier** to verify the behavior end-to-end, for example by closing several master positions at once.
* Choose the **protection mode** that matches your goal: `Close All only` to guard against accidental bulk closes, `Every close` if you never want to close in loss.
* Use **percent tolerance** rather than absolute currency when you copy to slaves of different sizes.
* Set a small **breakeven offset** (a few points) on symbols with meaningful commission or swap so held positions genuinely close flat.
* Use **per-symbol overrides** to widen the tolerance on high-spread instruments (gold, indices).
* If you combine it with **Max Open Positions**, keep in mind that held positions reduce the number of new trades that can be copied.
* **Turning the feature off** does not close held positions. Close them via the API if you want to exit them.
* Monitor the account **logs**: every blocked close, held partial close and breakeven Take Profit is recorded there.
