AlgoDeltaFXDocs
POST

Close Position

Account API v2

Close an open position fully or partially by ticket, or close all positions on a symbol.

POSThttps://api.algodeltafx.com/api/v2/forexaccount/squareoffposition

Square off open MetaTrader 5 positions. Close one position by ticket (optionally only part of its volume), or close every position on a symbol, optionally only the BUY or SELL side.

View .md Ask Claude Ask ChatGPT

Authentication

Send the account token as Authorization: Bearer <ACCOUNT_TOKEN>. See Authentication.

Request body

JSON body, Content-Type: application/json.

  • ticketinteger

    Ticket of the position to close.

  • volumenumber

    Lots to close for a partial close. Used with ticket. Omit to close the full position.

  • symbolstring

    Close positions on this symbol. Use instead of ticket.

  • sidestring · BUY | SELL

    Only close BUY or SELL positions on symbol. Omit to close both sides.

Response

Returns the standard response envelope: status, msg and data.

Notes

  • Send either ticket (with optional volume), or symbol (with optional side).
  • Get Open Positions: List every open position on the MT5 account.
  • Place Order: Open a market order or place a pending order (limit, stop, stop-limit) on an MT5 account.
  • Cancel Order: Cancel a pending order by ticket, or all pending orders for a symbol and side.

Try it

Live API
Request body (JSON)

This sends a live request that can change real trades or accounts. Use a demo account to experiment.

Requests go straight from your browser to api.algodeltafx.com. Your token is not sent anywhere else.

Example request

curl -X POST https://api.algodeltafx.com/api/v2/forexaccount/squareoffposition \
  -H "Authorization: Bearer $ACCOUNT_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
  "symbol": "EURUSD"
}'

Partial close by ticket

curl -X POST https://api.algodeltafx.com/api/v2/forexaccount/squareoffposition \
  -H "Authorization: Bearer $ACCOUNT_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
  "ticket": 1093765759,
  "volume": 0.25
}'

Close all SELL positions on a symbol

curl -X POST https://api.algodeltafx.com/api/v2/forexaccount/squareoffposition \
  -H "Authorization: Bearer $ACCOUNT_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
  "symbol": "EURUSD",
  "side": "SELL"
}'

Last updated 2026-11-04