# moveStops: Change the stop loss and/or take profit of one position

> Change the stop loss and/or take profit of one position. Parameters, units, copy-ready examples, log lines and errors for the moveStops command.

Source: https://zb-connector.com/docs/commands/movestops/

Change the stop loss and/or take profit of one position.

> **Use a demo account first.** Run every step on a MetaTrader 5 demo account. Switch to a live account only after the go-live checklist is done.

## At a glance

-   **Action:** `moveStops` (case-sensitive)
    
-   **Group:** Change stops and trailing
    
-   **From the dashboard:** yes, on the **Send Command** page
    
-   **Finds the position by:** `positionID` (the comment you gave it when you opened it) or `ticket`
    
-   **HTTP 200 means queued, not executed.** See [how delivery works](https://zb-connector.com/docs/reliability/how-delivery-works/) and [find where an alert stopped](https://zb-connector.com/docs/troubleshooting/find-where-it-stopped/).
    

## Fields

| Field | Type | Required | Unit | Description |
| --- | --- | --- | --- | --- |
| `license` | string | Yes | text | Your license key. In examples it is written `YOUR_LICENSE_KEY`. |
| `action` | string | Yes | text | Always `moveStops`. Case-sensitive. |
| `positionID` | string | Yes, or `ticket` | text | The position’s MT5 comment (the `positionID` you sent when opening it). If the value is all digits and no comment matches, it is matched against the position ticket. |
| `ticket` | integer | No | MT5 ticket | MT5 ticket of the position. Used only when `positionID` is empty. Allowed: greater than 0. Needs EA v1.9.1 or later. |
| `sl` | number | No | price level | New stop loss as a price level, whatever the Stop level mode input says. `0` or omitted keeps the current stop loss. Allowed: 0 or more. |
| `tp` | number | No | price level | New take profit as a price level. `0` or omitted keeps the current take profit. Allowed: 0 or more. |

Send at least one of `sl` and `tp` with a value above 0.

The webhook rejects unknown fields, missing required fields and wrong types with HTTP 422 before anything is queued. Field names are case-sensitive.

## Examples

Replace `YOUR_LICENSE_KEY` with your key. Send the body as the alert message in TradingView, or with any HTTP client.

### Move the stop loss and the take profit

**JSON**

```json
{
  "license": "YOUR_LICENSE_KEY",
  "action": "moveStops",
  "positionID": "eurusd_breakout_1",
  "sl": 1.085,
  "tp": 1.105
}
```

**curl**

```bash
curl -X POST "https://dev.api.zb-connector.com/webhook/" \
  -H "Content-Type: application/json" \
  -d '{"license":"YOUR_LICENSE_KEY","action":"moveStops","positionID":"eurusd_breakout_1","sl":1.085,"tp":1.105}'
```

**Python**

```python
import requests

payload = """
{
  "license": "YOUR_LICENSE_KEY",
  "action": "moveStops",
  "positionID": "eurusd_breakout_1",
  "sl": 1.085,
  "tp": 1.105
}
"""

response = requests.post(
    "https://dev.api.zb-connector.com/webhook/",
    data=payload,
    headers={"Content-Type": "application/json"},
    timeout=10,
)
print(response.status_code, response.text)
```

**Node.js**

```js
const response = await fetch("https://dev.api.zb-connector.com/webhook/", {
  method: "POST",
  headers: { "Content-Type": "application/json" },
  body: JSON.stringify({
    "license": "YOUR_LICENSE_KEY",
    "action": "moveStops",
    "positionID": "eurusd_breakout_1",
    "sl": 1.085,
    "tp": 1.105
  }),
});
console.log(response.status, await response.text());
```

### Move only the stop loss

**JSON**

```json
{
  "license": "YOUR_LICENSE_KEY",
  "action": "moveStops",
  "positionID": "eurusd_breakout_1",
  "sl": 1.087
}
```

**curl**

```bash
curl -X POST "https://dev.api.zb-connector.com/webhook/" \
  -H "Content-Type: application/json" \
  -d '{"license":"YOUR_LICENSE_KEY","action":"moveStops","positionID":"eurusd_breakout_1","sl":1.087}'
```

**Python**

```python
import requests

payload = """
{
  "license": "YOUR_LICENSE_KEY",
  "action": "moveStops",
  "positionID": "eurusd_breakout_1",
  "sl": 1.087
}
"""

response = requests.post(
    "https://dev.api.zb-connector.com/webhook/",
    data=payload,
    headers={"Content-Type": "application/json"},
    timeout=10,
)
print(response.status_code, response.text)
```

**Node.js**

```js
const response = await fetch("https://dev.api.zb-connector.com/webhook/", {
  method: "POST",
  headers: { "Content-Type": "application/json" },
  body: JSON.stringify({
    "license": "YOUR_LICENSE_KEY",
    "action": "moveStops",
    "positionID": "eurusd_breakout_1",
    "sl": 1.087
  }),
});
console.log(response.status, await response.text());
```

## What you see

After a successful run the MT5 **Experts** log shows:

```text
SL/TP updated for ticket <ticket> → SL: <sl>, TP: <tp>
```

In the dashboard, the command appears in **Command History** on the License Details page. [What each status means](https://zb-connector.com/docs/troubleshooting/find-where-it-stopped/#where-to-look).

## Errors and fixes

| Where you see it | Message or code | Cause | Fix |
| --- | --- | --- | --- |
| MT5 Experts log | `❌ handleCommand: moveStops needs positionID and at least one of SL/TP>0` | The position reference is missing, or both `sl` and `tp` are 0 or missing. | Send `positionID` (or `ticket`) and at least one of `sl` / `tp` above 0. |
| MT5 Experts log | `moveStops: Position with ID <positionID> not found` | No open position in the EA’s trade scope matches. | Check the position’s comment or ticket in MT5. |
| Broker, MT5 return code | [10016 Invalid stops in the request](https://zb-connector.com/docs/troubleshooting/errors/10016/) | The new stop is on the wrong side of the price or too close to it. | Check the value against the current price and the symbol’s stop level. |
| Broker, MT5 return code | 10025 No changes in request | The values are the same as the current ones. | Nothing to change. |

## Notes

-   Unlike long and short, moveStops always reads sl and tp as price levels.
-   Only the first matching position is changed.
-   Only positions in the EA’s trade scope are considered (by default, trades opened by this EA).

## Related

-   [Commands overview](https://zb-connector.com/docs/commands/overview/) and the [cheat sheet](https://zb-connector.com/docs/commands/cheatsheet/)
-   [moveStopsBreakeven](https://zb-connector.com/docs/commands/movestopsbreakeven/): move the stop loss of one position to its entry price, with an optional offset
-   [setTrailingStop](https://zb-connector.com/docs/commands/settrailingstop/): attach a trailing stop to one position
