Docs / User guides / Position protections

Position protections

Give an open position a trailing stop, a break-even, a stop ladder, take-profit levels that close it in parts, or a time exit. The trading server runs them next to the terminal, so they keep working when the control plane or your own program is offline.

Updated 16 Nov 2026·Version 0.x
New in 1.2.0-beta. Protections need an MT5 deployment in risk mode on the runtime image main-213a8d4 or later. See What you need.

1. What a protection does

A stop loss and a take profit are fixed prices that the broker holds. A protection adds rules that move or use those levels while the position is open. Each position can have one protection, made of any of these rules:

RULEWHAT IT DOESEXAMPLE
Trailing stopThe stop loss follows the price at a distance, and never moves back.Once 10 pips in profit, keep the stop 20 pips behind the price, moving in 1-pip steps.
Break-evenMoves the stop loss to the open price (plus a little) after a profit.After 15 pips of profit, stop at open + 1 pip.
Stop ladderLocks in more profit at each step.At +30 pips lock 10; at +60 pips lock 40.
Take-profit levelsCloses part of the position at each level. The last level is also the broker's take profit.Close 40% at +20 pips, 30% at +40, the last 30% at +80.
Time exitCloses the whole position at a time, or after a holding time.Close at 16:55 before the weekend, or after 4 hours.

Distances can be given in pips, points, % of price, money (in the account currency, for the position's current volume) or % of balance. The trading server converts them to prices from the quote it sees at that moment, and rounds so that a stop is never looser than you asked.

A buy position opened at 1.0800 with a trailing stop of 20 pips. As the price rises to 1.0830 and 1.0860, the stop loss moves up behind it to 1.0810 and 1.0840. When the price falls back to 1.0840, the stop closes the position with 40 pips of profit. Take-profit levels at +20 and +40 pips closed 40 and 30 percent of the volume on the way up. open 1.0800 stop → open (break-even) trailing: 20 pips behind TP 1: close 40% TP 2: close 30% high 1.0860 stopped out Buy EURUSD: price (black) and stop loss (red)
One buy position with a break-even, a trailing stop and two take-profit levels. Each rule only ever tightens the stop or closes volume.
Where it runs. The rules are evaluated by the risk service of the deployment, on the trading server, on every fresh read of the terminal. They keep working when the control plane, the dashboard or your program is offline. They stop only when the deployment stops; the broker's stop loss and take profit stay as the floor in that case. When the service cannot be sure of the account (no quote, terminal disconnected, an order whose outcome is not known yet), no rule fires and the dashboard shows the rule as Paused with the reason.

2. What you need

  • An MT5 account whose deployment was created with Run in risk mode, on a server added with Allow risk mode.
  • The MetaTrader 5 runtime image main-213a8d4 or later. Approve it under Servers → Images, then re-create the deployment on it. An older image answers not_supported_by_terminal.
  • The permission positions:modify on the account (an API token with Full access has it).
  • A symbol on which the broker accepts a stop loss and take profit.

3. Protect a position in the dashboard

  1. Open the trading account, its Orders tab, and under Open positions press Protect on the position.
  2. Turn on the rules you want. For each, enter the distances and choose the unit. Under Distances count from, keep The open price.
  3. For take-profit levels, the shares are percent of the opening volume and must add up to 100.
  4. Press Save changes. The panel shows Waiting for the host to take it, then Active on the host within seconds, with the state of each rule (armed, active, done) and the last action.
The Protect position panel with a trailing stop, break-even and take-profit levels
Protect position: each rule has a switch, a distance and a unit.

The position then shows chips that sum up its protection, such as Trailing 12 pips, Break-even at 10 pips and TP 2 levels. Next to them are Edit SL/TP, Protection, Close part and Close. Every stop move and partial close the protection makes appears on the Orders tab, marked as made by the protection, with the conversion it used. Remove ends the protection; the broker's stop loss and take profit stay where they are.

A position with an active protection summary in the Positions card
A protected position: the summary shows which rules it has.

Protect the position an order opens

In the New order form, tick Protect the position this order opens and fill in the same rules. The protection starts as soon as the order fills. You can also give the order's own stop loss and take profit as a distance: choose the unit under Stop loss in and Take profit in.

The New order form with a market order, stop loss and take profit in pips
A market order with a stop loss of 20 pips and a take profit of 40 pips.

4. With the Trading API

Set or replace the protection of an open position:

curl -X PUT \ "https://connect.example.com/api/v1/trading/accounts/tac-oyedut4bv5qc6zhz/positions/51234567/protection" \ -H "Authorization: Bearer $PB_TOKEN" \ -H "Content-Type: application/json" \ -d '{ "trailing_stop": {"activate": {"value": "10", "unit": "pips"}, "distance": {"value": "20", "unit": "pips"}}, "break_even": {"trigger": {"value": "15", "unit": "pips"}, "offset": {"value": "1", "unit": "pips"}}, "take_profits": [{"level": {"value": "20", "unit": "pips"}, "share": 40}, {"level": {"value": "40", "unit": "pips"}, "share": 30}, {"level": {"value": "80", "unit": "pips"}, "share": 30}], "time_exit": {"after": 14400} }'

The answer is the stored protection with its revision, state and the state of each rule. GET …/protection reads it with the orders it produced, DELETE …/protection removes it, and GET /v1/trading/accounts/{account_id}/protections lists all of an account's protections.

Or open a position and protect it in one request: a market order with its stops as distances and a protection. Stops given as a distance need an account in risk mode; a plain price, such as "stop_loss": "1.0780", works on every MT5 account.

curl -X POST "https://connect.example.com/api/v1/trading/accounts/tac-oyedut4bv5qc6zhz/orders" \ -H "Authorization: Bearer $PB_TOKEN" \ -H "Content-Type: application/json" \ -d '{ "client_order_id": "ema-0412-1", "symbol": "EURUSD", "side": "buy", "type": "market", "volume": "0.10", "stop_loss": {"value": "20", "unit": "pips"}, "take_profit": {"value": "80", "unit": "pips"}, "protection": { "trailing_stop": {"distance": {"value": "20", "unit": "pips"}} } }'

A position can also be closed in part, on the same runtime image: POST …/positions/{position_id}/close with {"client_order_id": "part-1", "volume": "0.05"}. The volume must be on the symbol's volume step and at most the position's volume; without it the whole position closes.

The fields

FIELDRULES
trailing_stopdistance required; activate (profit before it starts, default 0) and step (smallest move) optional.
break_eventrigger required; offset towards profit, default 0. Fires once.
stop_ladder1 to 10 rows of threshold (rising) and stop (the profit to lock, not falling).
take_profits1 to 5 rows of level and share; the shares are whole percents adding up to exactly 100. The last row is set as the broker's take profit.
time_exitOne of at (a UTC time in the future) or after (seconds since the position opened, 60 to 2 592 000).
anchoropen (default): distances count from the open price. fill: on an order, also re-set the order's stops once from the real fill price.
A distance{"value": "20", "unit": "pips"}; units pips, points, percent, money, percent_balance, or price for an absolute level.

When several rules want a stop in the same moment, the one best for you wins (the highest stop for a buy, the lowest for a sell), and one change is sent.

5. Good to know

  • Protections only tighten or close. They never move a stop against you and never open a position. They work during an emergency halt for stop moves; closes follow the halt's close rules.
  • The stop moves at most every 5 seconds per position, and by at least one point. A broker that answers "too many requests" pauses the account's protections for 30 seconds.
  • A rule that fired never fires again, also after a restart or a failover: the trading server keeps a journal of every action.
  • Money and % of balance need the terminal to report the symbol's tick value; otherwise use pips (unit_unavailable).
  • A position opened outside PerkBridge can be protected too; the panel says so.
  • Up to 200 protected positions per deployment.
ANSWERMEANING
protections_unavailableThe account is not in risk mode.
not_supported_by_terminalThe deployment runs an image older than main-213a8d4. Re-create it on the new image.
position_not_foundThe position is not open in the last report.
stops_not_supportedThe broker does not accept stops on this symbol.
protection_invalidA field is wrong; the answer names it.
unit_unavailableMoney or % of balance on a symbol without a tick value.
Was this page helpful?