---
url: /safety-and-reliability/position-protection.md
description: >-
  How TTMT protects open positions with breakeven, Lock in profit at each TP,
  trailing stops, TP redistribution, conflict prevention, P&L recovery, and safe
  modification.
---

# Position Protection

Once a trade is open, the work is far from done. Markets reverse, brokers disconnect, and positions need continuous management. TTMT monitors every open position in real time and applies multiple layers of protection to preserve capital and lock in profits.

This page covers every system that guards your positions after execution.

***

## Breakeven

When a take-profit target is hit, TTMT can automatically move the stop loss to the entry price (plus a buffer), effectively locking in a risk-free trade. With **Breakeven once in profit** on, it can also do this once the trade is a set distance in profit, before any target. This is one of the most impactful safety features in the system.

### How It Works

```mermaid
flowchart TD
    A["TP1 Hit\n(position closes at TP)"] --> B["Breakeven triggered"]
    B --> C["Calculate new SL:\nEntry Price + Buffer"]
    C --> D["Queue modification\n(HIGH priority)"]
    D --> E["Submit modification"]
    E --> F{"Modification\nAccepted?"}
    F -->|"Yes"| G["Start 15s verification"]
    F -->|"No"| H["Retry (200ms → 2s)\nUp to 5 attempts"]
    H --> E
    G --> I{"Verified on\nbroker?"}
    I -->|"Yes"| J["Breakeven confirmed\n(marked as active)"]
    I -->|"No"| K["Flag for\nrecovery service"]

    style A fill:#0d4f3c,stroke:#36d399,color:#d6fff0
    style J fill:#0d4f3c,stroke:#36d399,color:#d6fff0
    style K fill:#5a4708,stroke:#e7c000,color:#fff6d6
```

### Parameters

| Parameter | Value | Configurable? |
|:----------|:-----:|:-------------:|
| **Default trigger** | TP1 hit | Yes -- **Auto-Breakeven** in Settings › Protect open trades: **Never**, or **TP1** to **TP6** |
| **Profit trigger** | Off | Yes -- **Breakeven once in profit**, in pips, R or money |
| **Buffer** | 2 pips above/below entry | Yes -- **Lock in a small profit**, in pips |
| **Retry profile** | Breakeven (fastest) | No -- always uses fastest retries |
| **Initial retry delay** | 200ms | No |
| **Max retry delay** | 2s | No |
| **Max retries** | 5 | No |
| **Verification timeout** | 15 seconds | No |

### The 2-Pip Buffer

The buffer is not optional for safety reasons. Setting breakeven exactly at entry price is dangerous because:

1. **Spread fluctuation** can trigger the stop even when price has not truly reversed.
2. **Slippage** on the stop execution could turn a breakeven into a small loss.
3. **Overnight swaps** can shift the effective position value slightly.

The 2-pip buffer (default) accounts for all three. You can adjust it, but setting it to 0 is not recommended.

### Breakeven Triggers

Breakeven can be activated through six independent triggers, so a single missed event never leaves a stop unmoved:

| Trigger | What Sets It Off | When |
|:--------|:-----------------|:-----|
| **Automatic on TP hit** | The breakeven manager moves the stop when a take-profit is hit | Primary path -- fastest response |
| **Live take-profit handler** | The live trade monitor catches the TP hit directly and moves the stop inline | Backstop to the primary path |
| **Breakeven retry service** | A queued breakeven that didn't confirm is retried | Recovers from a delayed or failed first attempt |
| **Position reconciliation** | A periodic check finds a TP was hit while TTMT was out of touch | Safety net for disconnections |
| **Signal-driven breakeven** | The channel sends a breakeven instruction | Channel-driven modification |
| **Breakeven once in profit** | The trade is the distance you set in profit, measured from the worst filled entry | Off by default; fires once per trade |

::: info
The breakeven status is historical audit data. Once marked as active, it is never cleared -- even after the trade closes. This provides a permanent record of whether breakeven was applied, useful for performance analysis.
:::

### Lock in profit at each TP

With **Lock in profit at each TP** on (off by default, marked **Experimental**), the stop keeps moving after breakeven. When price reaches a TP, the stop goes to the price of an earlier TP: the previous TP, or 2 or 3 TPs earlier, as set in **Stop goes to**.

| Price reaches | BUY EURUSD at 1.1000, stop 1.0960 | SELL EURUSD at 1.1000, stop 1.1040 |
|:--|:--|:--|
| TP1 | 1.1002 (breakeven, 2-pip buffer) | 1.0998 (breakeven, 2-pip buffer) |
| TP2 | 1.1020 (TP1) | 1.0980 (TP1) |
| TP3 | 1.1040 (TP2) | 1.0960 (TP2) |

*Example with breakeven at TP1 and **Previous TP**; BUY TPs at 1.1020 / 1.1040 / 1.1060, SELL TPs at 1.0980 / 1.0960 / 1.0940.*

These moves follow their own safety rules:

* TTMT never moves the stop back.
* If a move can't be placed, the stop stays where it is and TTMT tries again every few seconds. It never closes a position for this.
* With Lock in profit at each TP on, Auto-Breakeven also waits instead of closing. A channel's "move to breakeven" message, your own Set breakeven, and the checks that catch up on a missed breakeven still follow **If the stop can't move to entry in time**. They can still close.
* While it is on, a channel stop move that would loosen your stop is not applied, and you are told.

See [Lock in profit at each TP](/core-concepts/breakeven-management#lock-in-profit-at-each-tp) for the full rules.

### Preserving the Breakeven Intent

Once breakeven is triggered, TTMT records the intended breakeven stop in your records **before** sending it to the broker. This preserves the breakeven intent even if broker confirmation is delayed or a redistribution runs at the same moment. A redistribution can no longer silently overwrite a just-set breakeven stop: the recorded intent is the source of truth, and a delayed confirmation is reconciled against it rather than lost.

***

## Trailing Stop

A trailing stop follows price at a fixed distance as price moves your way. Once the stop passes entry, it locks in gains. Breakeven moves the SL once, and Lock in profit at each TP moves it to TP prices. Trailing instead keeps adjusting the SL to hold a fixed distance from the current price.

### How the trailing stop works

The trailing stop works the same on MetaAPI Cloud and on TTMT Direct.

* **When it starts.** You choose when it starts: after breakeven, after a TP, after a number of pips in profit, at once, or after an amount of profit.
* **Which positions.** You choose which positions it moves: the last TP only, or every open position.
* **Distance and pace.** The stop follows price at the distance you set, in pips. It moves at most once every 15 seconds.
* **Direction.** It never moves a stop further from price. When breakeven or Lock in profit at each TP would place a better stop, that stop is used.
* **Who moves it.** TTMT moves the stop. While your TTMT service is restarting or cannot reach your broker, the stop stays where it is. After a restart, trailing waits 15 minutes, then continues, normally within 1 more minute.
* **If you change the setting.** A position that is already trailing keeps its distance when you change the setting.
* **If you change the stop.** Changing the stop yourself, or a channel message that sets a new stop, ends trailing for those positions.

### Preservation During Modifications

A trailing stop that TTMT moves is not a broker setting, so a breakeven move cannot remove it. The position keeps trailing after the breakeven move. A Cloud position that started trailing before this update keeps MetaAPI's trailing: TTMT re-sends its trailing settings with every stop change.

***

## TP Redistribution V2

When price retraces and deeper entry layers fill, TP Redistribution re-spreads the take-profit targets of the positions you hold so they match your TP strategy again, and locks Layer 1 to TP1. A signal is split into layers -- four by default, configurable up to six -- and redistribution responds as those layers fill. This system is covered in detail in the [Order Management System](/core-concepts/order-management) reference; this section focuses on the safety mechanisms.

### Layer 1 Lock

The most important redistribution rule: **when any deeper layer fills, all Layer 1 positions lock to TP1.**

Layer 1 positions entered at the worst price (market price when the signal fired). If the market retraces enough to fill deeper layers, these Layer 1 positions are the most at risk. Locking them to TP1 ensures they close at the earliest opportunity, securing whatever profit the initial move provided.

This is a **user-tunable setting**, on by default. With the Layer 1 lock on, the behavior above applies. With it off, Layer 1 joins the normal redistribution alongside the other layers instead of locking to TP1. The switch is **Keep layer 1 on TP1 when that happens** (formerly L1 Safety Lock) under **Settings › Protect open trades**, in Full view ([Active Trade Setup](/trade-config/active-trade-setup)); leave it on unless you specifically want Layer 1 to chase further targets.

Under the **Most at last TPs** take-profit strategy there is one exception: the lock applies to all Layer 1 positions *except the largest* (the first, when they are the same size), so that entry can still run toward a deeper target while the rest secure profit.

### Failure Handling

Redistribution involves modifying multiple positions on the broker. If some modifications fail:

| Failure Rate | Response |
|:-------------|:---------|
| **< 25% of modifications fail** | Record partial success, continue. The failed positions keep their previous TPs. |
| **>= 25% of modifications fail** | Mark the trade for automatic retry. The retry service picks it up within 60 seconds. |

### Position-Count-Aware Skip

The system tracks how many positions were open during the last redistribution. If a redistribution is triggered but the position count has not changed since the last run, the redistribution is skipped -- it would produce the same result.

This prevents wasted broker operations and avoids unnecessary modifications that could fail and trigger the failure threshold.

### TP-Match Skip

Before modifying a position, the system checks whether the position's current TP already matches the target TP. If it does, the modification is skipped. This is a simple but important optimization that reduces broker operations and prevents unnecessary modification events.

### Reliability Enhancements

For the deepest layers (Layer 4), which hold the best entry price, the system uses enhanced reliability:

| Layer | Retry Strategy |
|:------|:---------------|
| **Layer 4** | Retry failed modifications + 8-second verification to confirm state |
| **Layers 2-3** | 2 retries, then stop (self-healing via next layer fill event) |
| **Layer 1** | Locked to TP1 -- simplest modification, highest success rate |

***

## Conflict Prevention

When multiple events affect the same position simultaneously (e.g., a TP hit and a signal modification arrive at the same time), conflicting modifications could corrupt state. TTMT's conflict prevention system handles this.

### How It Works

TTMT processes one modification at a time for each position. When any operation needs to close or significantly modify a position, it ensures no other operation is working on the same position. If another operation is already in progress, the new operation waits briefly.

### Primary / Fallback Pattern

The system uses a primary/fallback pattern to ensure cleanup even if the primary operation fails:

```mermaid
flowchart TD
    A["Event: Close Position"] --> B{"Can proceed?"}
    B -->|"Yes"| C["Execute primary close"]
    B -->|"Another operation in progress"| D["Log conflict + skip"]
    C -->|"Success"| E["Done"]
    C -->|"Failure"| F["Execute fallback close"]
    F --> E

    style C fill:#0d4f3c,stroke:#36d399,color:#d6fff0
    style D fill:#5a4708,stroke:#e7c000,color:#fff6d6
    style F fill:#5e1620,stroke:#ed3c50,color:#ffe1e4
```

The fallback ensures that even if the primary closure method fails (e.g., a broker call times out), an alternative approach is tried before giving up.

::: warning
If an operation takes too long (likely a broker timeout), the system releases it and allows subsequent operations to proceed.
:::

***

## P\&L Recovery

Positions can close outside of TTMT's direct awareness. A trailing stop might fire during a brief disconnection. A broker might execute a margin call. A manual close from the MetaTrader terminal would not generate a TTMT event. The background P\&L recovery system catches all of these.

### What It Does

1. Compares TTMT's list of "open" positions against the broker's actual open positions.
2. Identifies positions that TTMT thinks are open but the broker says are closed.
3. Queries the broker's deal history to find the closing deal and extract the actual P\&L.
4. Updates TTMT's trade record with the correct close price, close time, and P\&L.
5. Triggers any downstream actions (trade status update, performance recalculation).

TTMT periodically checks for these discrepancies. If the closing deal is not immediately available in the broker's history, TTMT retries automatically with increasing wait times until the information is found.

### Trade Status Self-Healing

A trade can briefly close before its real profit or loss has landed from the broker. To make sure your trade log never shows the wrong outcome, TTMT continuously reconciles each trade's final win/loss status against the actual closed-position result.

If a trade was provisionally marked closed before its real P\&L arrived, a self-healing reconciliation corrects the status once the true figure lands. While the figure is still unknown, TTMT defaults conservatively -- an unconfirmed close is treated as a loss until proven otherwise, never as a phantom profit. The takeaway: your trade log reflects the real outcome, and a trade is never left showing a profit it didn't actually make.

A related hardening makes closure writes wait on a single "closed" condition, so a position closing and its P\&L arriving a moment later can't race each other into a wrong final status.

***

## Order Fill Recovery

When a limit order fills, TTMT needs to know about it to update the trade state, trigger redistribution, and manage the new position. If a fill happens during a disconnection, the 3-layer recovery defense ensures it is not missed.

### 3-Layer Defense

| Layer | Method | Latency | Reliability |
|:------|:-------|:-------:|:------------|
| **1. Live reconnect** | Broker resynchronization delivers missed events | Seconds | Catches ~99% of cases |
| **2. Direct query fallback** | Direct query to broker order/deal history | Brief delay + retries | Catches edge cases |
| **3. Admin alert** | Notification for manual review | Manual | Last resort for exceptional failures |

**Layer 1** is the normal path. When TTMT reconnects after a disconnection, the synchronization process replays events that occurred while TTMT was disconnected.

**Layer 2** activates if the live resync does not include the expected fill event. TTMT directly queries the broker's history with a small delay (to give the broker time to populate history) and retries to confirm the fill.

**Layer 3** is the absolute last resort. If both automated recovery methods fail, an alert is generated for administrative review. In practice, this is extremely rare.

***

## Safe Position Modification

All position modifications in TTMT go through a single safe modification process. This exists because modifying a position on the broker has important side effects that must be carefully managed.

### What It Preserves

| State | How It Is Preserved |
|:------|:-------------------|
| **Trailing stop** | Kept: TTMT's trailing is not a broker setting; an older MetaAPI trailing setting is re-sent with the change |
| **Breakeven state** | The breakeven status in your records is not affected by modification |
| **Open TP** | Positions with "open TP" (runner mode) retain their open TP status |

### Why This Matters

Without this safe modification process, a stop change could drop the position's take-profit. The broker's modification call replaces all parameters. It does not merge them. A Cloud position that started trailing before this update would also lose its older MetaAPI trailing setting.

TTMT's safe modification reads the current position state, merges the intended change with all existing parameters, and submits the complete state in a single update.

::: danger
Every part of TTMT that modifies positions uses this safe modification process. Direct broker modification calls are prohibited. This ensures your take-profits and your trailing are never accidentally removed.
:::

***

## Summary

| System | What It Protects | When It Acts |
|:-------|:-----------------|:-------------|
| **Breakeven** | Locks in profit after TP hit | TP1 hit (or configured TP) |
| **Trailing Stop** | Follows price as it moves your way, on both providers | At most every 15 seconds while active |
| **TP Redistribution V2** | Re-spreads targets to your TP strategy as layers fill | When deeper layers fill |
| **Conflict Prevention** | Prevents conflicting modifications | Concurrent position events |
| **P\&L Recovery** | Reconciles externally closed positions | Periodically |
| **Order Fill Recovery** | Catches fills missed during disconnection | After reconnection |
| **Safe Position Modification** | Keeps take-profits, breakeven state and trailing during modifications | Every position modification |

::: tip
All position protection systems work together automatically. Breakeven never ends trailing. TP redistribution respects the conflict prevention system. P\&L recovery feeds accurate data back to the performance dashboard. You do not need to manage the interactions between these systems -- they are designed to complement each other.
:::

***

## Related pages

* [Safety & Reliability Overview](/safety-and-reliability/) -- The five layers of defense
* [Execution Safety](/safety-and-reliability/execution-safety) -- Automatic safety pauses and error handling
* [Connection Resilience](/safety-and-reliability/connection-resilience) -- Reconnection and state synchronization
* [Risk Limits](/safety-and-reliability/risk-limits-halt) -- The daily-loss halt, which can close open positions
* [Emergency Controls](/safety-and-reliability/emergency-controls) -- Manual intervention options
* [Breakeven Management](/core-concepts/breakeven-management) -- Detailed breakeven concepts
* [TP Redistribution](/core-concepts/tp-redistribution) -- Redistribution algorithm details
* [Order Management System](/core-concepts/order-management) -- Full adaptive order system reference
