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
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
ticket | integer | Yes | — | — |
dry_run | boolean | No | true | — |
Example Request
{
"tool": "close_position",
"arguments": {
"ticket": 123456,
"dry_run": true
}
}Usage Notes
- Keep
dry_run: trueuntil 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
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
ticket | integer | Yes | — | — |
stop_loss | number | No | — | — |
take_profit | number | No | — | — |
dry_run | boolean | No | true | — |
Example Request
{
"tool": "modify_position",
"arguments": {
"ticket": 123456,
"dry_run": true
}
}Usage Notes
- Keep
dry_run: trueuntil 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
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
symbol | string | Yes | — | — |
volume | number | Yes | — | — |
order_type | string | Yes | — | (one of: BUY, SELL, BUY_LIMIT, BUY_STOP, SELL_LIMIT, SELL_STOP) |
price | number | No | — | — |
stop_loss | number | No | — | — |
take_profit | number | No | — | — |
magic | integer | No | — | — |
comment | string | No | — | — |
expiry | integer | No | — | Pending orders only: expiration as unix epoch seconds (UTC). Must be in the future. |
dry_run | boolean | No | true | — |
Example Request
{
"tool": "place_order",
"arguments": {
"symbol": "EURUSD",
"volume": 1,
"order_type": "BUY",
"dry_run": true
}
}Usage Notes
- Keep
dry_run: trueuntil you have validated symbol, lot size, and expected execution behavior.