MTContext Docs
Tool Reference

Trading

3 tools in this category.

Overview

Trading includes 3 tools for this workflow area.

Available tools: close_position, modify_position, place_order.

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

close_position

Closes an open position by ticket. 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
dry_runbooleanNotrue

Example Request

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

Usage Notes

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

modify_position

Modifies the stop_loss and/or take_profit of an open position (a ticket in get_positions). Distinct from modify_pending_order (order-management.ts), which modifies a not-yet-filled pending order (a ticket in get_orders) and also accepts price/expiry. At least one of stop_loss or take_profit must be provided. 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
stop_lossnumberNo
take_profitnumberNo
dry_runbooleanNotrue

Example Request

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

Usage Notes

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

place_order

Places a market or pending order on MT5. Defaults to dry_run=true — set dry_run=false to execute live. Pending orders may set expiry (unix epoch seconds) for broker-side expiration; expiry is rejected on market orders. 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
symbolstringYes
volumenumberYes
order_typestringYes(one of: BUY, SELL, BUY_LIMIT, BUY_STOP, SELL_LIMIT, SELL_STOP)
pricenumberNo
stop_lossnumberNo
take_profitnumberNo
magicintegerNo
commentstringNo
expiryintegerNoPending orders only: expiration as unix epoch seconds (UTC). Must be in the future.
dry_runbooleanNotrue

Example Request

{
  "tool": "place_order",
  "arguments": {
    "symbol": "EURUSD",
    "volume": 1,
    "order_type": "BUY",
    "dry_run": true
  }
}

Usage Notes

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

On this page