# Modify Order or Position

Change the stop loss, take profit or price of an open position or pending order.

`POST https://api.algodeltafx.com/api/v2/forexaccount/modifyorderorposition`

- API: Account API (v2)
- Authentication: Send the account token as `Authorization: Bearer <ACCOUNT_TOKEN>`. See [Authentication](/authentication/).

Update the stop loss and take profit of an open MT5 position, or the price, SL, TP and stop-limit price of a pending order, by ticket. Use it for trailing stops, break-even moves and repricing pending orders from your own code.

## Request body (JSON)

| Name | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| `ticket` | integer | yes |  | MT5 ticket of the position or pending order. |
| `price` | number | no |  | New order price. Pending orders only. |
| `sl` | number | no |  | New stop loss price. |
| `tp` | number | no |  | New take profit price. |
| `stop_limit` | number | no |  | New limit price for stop-limit pending orders. |

## Example: cURL

```bash
curl -X POST https://api.algodeltafx.com/api/v2/forexaccount/modifyorderorposition \
  -H "Authorization: Bearer $ACCOUNT_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
  "ticket": 1093918439,
  "sl": 1.0856,
  "tp": 1.1589
}'
```

## Example: Python

```python
import os
import requests

res = requests.post(
    "https://api.algodeltafx.com/api/v2/forexaccount/modifyorderorposition",
    headers={"Authorization": f"Bearer {os.environ['ACCOUNT_TOKEN']}"},
    json={
        "ticket": 1093918439,
        "sl": 1.0856,
        "tp": 1.1589
    },
    timeout=30,
)
data = res.json()
print(data["status"], data.get("msg"), data.get("data"))
```

### Move a pending order

```json
{
  "ticket": 1093920001,
  "price": 1.0795,
  "sl": 1.075,
  "tp": 1.09
}
```

## Response

Standard envelope: `status` (boolean), `msg` (string), `data` (object or array).

## Notes

- Send only the fields you want to change along with `ticket`.
- Moving SL to the entry price creates a break-even stop. Call this endpoint repeatedly as price moves to build a trailing stop.

## Related

- [Place Order](https://docs.algodeltafx.com/api/place-order.md): Open a market order or place a pending order (limit, stop, stop-limit) on an MT5 account.
- [Get Open Positions](https://docs.algodeltafx.com/api/get-open-positions.md): List every open position on the MT5 account.
- [Get Pending Orders](https://docs.algodeltafx.com/api/get-pending-orders.md): List every pending (limit, stop, stop-limit) order on the MT5 account.


---
Source: https://docs.algodeltafx.com/api/modify-order/
