MTContext Docs
Tool Reference

Position Action

4 tools in this category.

Overview

Position Action includes 4 tools for this workflow area.

Available tools: close_all_positions, reverse_position, set_breakeven, set_trailing_stop.

Use the parameter tables and examples below as the canonical request contract.

close_all_positions

Closes all currently open positions, optionally filtered by symbol. The EA executes all closes in a single command to avoid N round-trips and partial-disconnect risk. Returns a results array with per-ticket success/failure. Defaults to dry_run=true — set dry_run=false to execute live. Requires the trade capability and inp_AllowTrading=true on the EA.

This tool can affect a live trading account. dry_run defaults to true — pass dry_run: false explicitly to execute for real.

Parameters

NameTypeRequiredDefaultDescription
symbolstringNo
dry_runbooleanNotrue

Example Request

{
  "tool": "close_all_positions",
  "arguments": {
    "dry_run": true
  }
}

Usage Notes

  • Keep dry_run: true until you have validated symbol, lot size, and expected execution behavior.

reverse_position

Closes an open position and opens a market order in the opposite direction as ONE EA command (single trade-context acquisition — minimises the gap between the two fills vs separate close_position + place_order calls). volume defaults to the closed volume; optional stop_loss / take_profit apply to the new position. If the close succeeds but the open fails (margin, market closed), returns REVERSE_PARTIAL with the close details and leaves the account flat — the EA never retries the open on its own. Defaults to dry_run=true — set dry_run=false to execute live. Requires the trade capability and inp_AllowTrading=true on the EA.

This tool can affect a live trading account. dry_run defaults to true — pass dry_run: false explicitly to execute for real.

Parameters

NameTypeRequiredDefaultDescription
ticketintegerYes
volumenumberNo
stop_lossnumberNo
take_profitnumberNo
dry_runbooleanNotrue

Example Request

{
  "tool": "reverse_position",
  "arguments": {
    "ticket": 123456,
    "dry_run": true
  }
}

Usage Notes

  • Keep dry_run: true until you have validated symbol, lot size, and expected execution behavior.

set_breakeven

Moves the stop loss of a position (or all positions) to its entry price. Optional buffer_points adds N points on the safe side of entry. Returns POSITION_NOT_IN_PROFIT if the position has not yet moved favourably. Defaults to dry_run=true — set dry_run=false to execute live. Requires the trade capability and inp_AllowTrading=true on the EA.

This tool can affect a live trading account. dry_run defaults to true — pass dry_run: false explicitly to execute for real.

Parameters

NameTypeRequiredDefaultDescription
ticketintegerNo
buffer_pointsintegerNo0
dry_runbooleanNotrue

Example Request

{
  "tool": "set_breakeven",
  "arguments": {
    "dry_run": true
  }
}

Usage Notes

  • Keep dry_run: true until you have validated symbol, lot size, and expected execution behavior.

set_trailing_stop

Registers a software trailing stop on a position. The EA updates the SL each timer cycle when price moves trailing_points in the position's favour. IMPORTANT: trailing state is lost if the EA restarts — callers should re-set after reconnect. trailing_points minimum is 10. Defaults to dry_run=true — set dry_run=false to register live. Requires the trade capability and inp_AllowTrading=true on the EA.

This tool can affect a live trading account. dry_run defaults to true — pass dry_run: false explicitly to execute for real.

Parameters

NameTypeRequiredDefaultDescription
ticketintegerYes
trailing_pointsintegerYes
dry_runbooleanNotrue

Example Request

{
  "tool": "set_trailing_stop",
  "arguments": {
    "ticket": 123456,
    "trailing_points": 1,
    "dry_run": true
  }
}

Usage Notes

  • Keep dry_run: true until you have validated symbol, lot size, and expected execution behavior.

On this page