Fields keep MT5's names and meanings, with readable values in place of MT5's numbers: "type": "buy_limit" is ORDER_TYPE_BUY_LIMIT, "type_filling": "ioc" is ORDER_FILLING_IOC.
Every trade call records one MqlTradeRequest and sends it once; every answer shows it as sent, field for field (whether it reached MT5 is the answer's state and result). Fields a call doesn't use carry MT5's empty values: 0, "", fok for type_filling and gtc for type_time.
| API field | MT5 field | Meaning |
|---|
action | action | What the request does. |
symbol | symbol | The symbol, exactly as the broker names it. |
type | type | The order type. |
volume | volume | Lots. |
price | price | The price: a pending order's, or the one instant and request execution trade at. |
stoplimit | stoplimit | A stop-limit order's limit price, placed once price is reached. |
sl | sl | Stop loss price; 0 for none. |
tp | tp | Take profit price; 0 for none. |
deviation | deviation | The largest difference from price MT5 accepts, in points. |
type_filling | type_filling | How the order may fill. |
type_time | type_time | How long a pending order lasts. |
expiration | expiration | Broker server time, seconds since 1970, as MT5 takes it. |
order | order | The pending order the request is about (modify, remove). |
position | position | The position the request is about (close, stops, close by). |
position_by | position_by | The opposite position, for close by. |
magic | magic | Your own number, kept by MT5 on the order, its deals and its position. |
comment | comment | Up to 31 characters, kept by MT5 on the order. |
What each call fills in, beyond the fields you send:
| Call | action | Also filled in |
|---|
| Place an order | deal for buy and sell, else pending | Nothing else. |
| Modify an order | modify | order from the path, and symbol from the pending order. |
| Cancel an order | remove | order from the path. |
| Set stops | sltp | position from the path, and symbol from the position. |
| Close a position | deal | position from the path; symbol from the position; type the other way (sell closes a buy). |
| Close by | close_by | position from the path, type: close_by, and symbol from the position. |
| Kill switch | remove for each pending order, deal for each position | For a close: the position's whole volume, the current bid or ask as price, the first filling mode the symbol allows (fok, else ioc, else return), your deviation, and the comment kill switch. |
Nothing else is set for you: no price for a market order, no filling mode, no rounding. A dry run sends the same request to MT5's OrderCheck without trading.
Place an order and Check an order:
| API field | MT5 field | Meaning |
|---|
symbol | symbol | The symbol exactly as the broker names it, such as EURUSD. |
type | type | What to send. |
volume | volume | Lots. |
type_filling | type_filling | How the order may fill. |
price | price | Required for pending orders: the price the order waits for. |
stoplimit | stoplimit | Required for buy_stop_limit and sell_stop_limit: the price of the limit order placed once price is reached. |
sl | sl | Stop loss price, set in the same request. |
tp | tp | Take profit price, set in the same request. |
deviation | deviation | The largest difference from price MT5 accepts, in points, for instant or request execution. |
type_time | type_time | How long a pending order lasts. |
expiration | expiration | When a pending order expires: broker server time, seconds since 1970. |
magic | magic | Your own number for the order, kept by MT5 on the order, its deals and its position. |
comment | comment | Up to 31 characters, kept by MT5 on the order. |
Modify an order:
| API field | MT5 field | Meaning |
|---|
price | price | The price the order waits for. |
sl | sl | Stop loss price; 0 removes it. |
tp | tp | Take profit price; 0 removes it. |
type_time | type_time | How long the order lasts. |
stoplimit | stoplimit | Required when the order is a stop-limit order: the price of the limit order placed once price is reached. |
expiration | expiration | When the order expires: broker server time, seconds since 1970. |
Close a position:
| API field | MT5 field | Meaning |
|---|
volume | volume | Lots to close: the position's whole volume, or part of it. |
type_filling | type_filling | How the closing deal may fill. |
price | price | Sent as given (0 if left out): brokers with instant or request execution need it, those with market or exchange execution ignore it. |
deviation | deviation | The largest difference from price MT5 accepts, in points, for instant or request execution. |
magic | magic | Your own number, kept by MT5 on the closing deal. |
comment | comment | Up to 31 characters, kept by MT5 on the closing deal. |
Set stops (PositionLevels) and Close by (CloseBy):
| API field | MT5 field | Meaning |
|---|
sl | sl | Stop loss price; 0 removes it. |
tp | tp | Take profit price; 0 removes it. |
| API field | MT5 field | Meaning |
|---|
position_by | position_by | The opposite position's ticket. |
A trade's result is MT5's MqlTradeResult:
| API field | MT5 field | Meaning |
|---|
retcode | retcode | MT5's return code: see Errors and retcodes. |
retcode_name | Pipsocket | The return code's name; UNKNOWN for a code MT5 doesn't document. |
comment | comment | The broker's comment on the answer. |
order | order | The order's ticket, if one was placed. |
deal | deal | The deal's ticket, if one was made. |
position | Pipsocket | The position's ticket, where the trade server gives it. |
volume | volume | The volume dealt. |
price | price | The price dealt. |
bid | bid | The bid when the request was handled (requotes). |
ask | ask | The ask when the request was handled (requotes). |
retcode_external | retcode_external | The external trading system's code, if the broker routes to one. |
A dry run's result is MT5's MqlTradeCheckResult:
| API field | MT5 field | Meaning |
|---|
passed | Pipsocket | Whether OrderCheck passed the request. |
retcode | retcode | MT5's return code: 0 when the check passed. |
retcode_name | Pipsocket | The return code's name; UNKNOWN for a code MT5 doesn't document. |
comment | comment | |
balance | balance | The balance after the trade. |
equity | equity | The equity after the trade. |
profit | profit | The floating profit after the trade. |
margin | margin | The margin the trade takes. |
margin_free | margin_free | The free margin after the trade. |
margin_level | margin_level | The margin level after the trade, in percent. |
Positions (POSITION_*):
| API field | MT5 field | Meaning |
|---|
ticket | POSITION_TICKET | The position's ticket: use it to close the position or set its stops. |
identifier | POSITION_IDENTIFIER | The position's id, which stays the same if the broker changes the ticket. |
symbol | POSITION_SYMBOL | |
type | Pipsocket | buy or sell (MT5's POSITION_TYPE). |
volume | POSITION_VOLUME | |
price_open | POSITION_PRICE_OPEN | |
sl | POSITION_SL | |
tp | POSITION_TP | |
magic | POSITION_MAGIC | |
comment | POSITION_COMMENT | |
time_msc | POSITION_TIME_MSC | When it was opened: broker server time, milliseconds since 1970. |
Pending orders (ORDER_*):
| API field | MT5 field | Meaning |
|---|
ticket | ORDER_TICKET | |
symbol | ORDER_SYMBOL | |
type | ORDER_TYPE | MT5's ENUM_ORDER_TYPE: buy and sell are market orders (ORDER_TYPE_BUY, ORDER_TYPE_SELL); buy_limit, sell_limit, buy_stop, sell_stop, buy_stop_limit and sell_stop_limit are pending orders (ORDER_TYPE_BUY_LIMIT and so on); close_by is ORDER_TYPE_CLOSE_BY. |
volume_initial | ORDER_VOLUME_INITIAL | |
volume_current | ORDER_VOLUME_CURRENT | |
price_open | ORDER_PRICE_OPEN | |
sl | ORDER_SL | |
tp | ORDER_TP | |
magic | ORDER_MAGIC | |
comment | ORDER_COMMENT | |
position | ORDER_POSITION_ID | The position the order belongs to, if any. |
Deals (DEAL_*), in history and on the stream:
| API field | MT5 field | Meaning |
|---|
ticket | DEAL_TICKET | |
order | DEAL_ORDER | The order that made the deal. |
position | DEAL_POSITION_ID | The position's id (identifier). |
symbol | DEAL_SYMBOL | |
type | Pipsocket | MT5's DEAL_TYPE: buy, sell, or a balance operation. |
entry | Pipsocket | MT5's DEAL_ENTRY: in opens or adds, out closes, inout reverses, out_by closes by an opposite position. |
reason | Pipsocket | MT5's DEAL_REASON: who or what made the deal (expert for the API, sl, tp, so for a stop out). |
volume | DEAL_VOLUME | |
price | DEAL_PRICE | |
profit | DEAL_PROFIT | |
commission | DEAL_COMMISSION | |
swap | DEAL_SWAP | |
fee | DEAL_FEE | |
magic | DEAL_MAGIC | |
comment | DEAL_COMMENT | |
time_msc | DEAL_TIME_MSC | Broker server time, milliseconds since 1970. |
Past orders:
| API field | MT5 field | Meaning |
|---|
ticket | ORDER_TICKET | |
symbol | ORDER_SYMBOL | |
type | ORDER_TYPE | MT5's ENUM_ORDER_TYPE: buy and sell are market orders (ORDER_TYPE_BUY, ORDER_TYPE_SELL); buy_limit, sell_limit, buy_stop, sell_stop, buy_stop_limit and sell_stop_limit are pending orders (ORDER_TYPE_BUY_LIMIT and so on); close_by is ORDER_TYPE_CLOSE_BY. |
state | Pipsocket | MT5's ORDER_STATE. |
volume_initial | ORDER_VOLUME_INITIAL | |
volume_current | ORDER_VOLUME_CURRENT | |
price_open | ORDER_PRICE_OPEN | |
magic | ORDER_MAGIC | |
comment | ORDER_COMMENT | |
position | ORDER_POSITION_ID | |
time_setup_msc | ORDER_TIME_SETUP_MSC | Broker server time, milliseconds since 1970. |
time_done_msc | ORDER_TIME_DONE_MSC | Broker server time, milliseconds since 1970. |
A symbol (SYMBOL_*):
| API field | MT5 field | Meaning |
|---|
name | SYMBOL_NAME | |
available | Pipsocket | Whether the terminal could read its properties; when false the rest are empty values. |
description | SYMBOL_DESCRIPTION | |
digits | SYMBOL_DIGITS | |
point | SYMBOL_POINT | |
tick_size | SYMBOL_TRADE_TICK_SIZE | |
tick_value | SYMBOL_TRADE_TICK_VALUE | |
contract_size | SYMBOL_TRADE_CONTRACT_SIZE | |
volume_min | SYMBOL_VOLUME_MIN | |
volume_max | SYMBOL_VOLUME_MAX | |
volume_step | SYMBOL_VOLUME_STEP | |
stops_level | SYMBOL_TRADE_STOPS_LEVEL | The closest stops may be to the price, in points. |
freeze_level | SYMBOL_TRADE_FREEZE_LEVEL | How close to the price an order or stop is frozen, in points. |
filling_mode | SYMBOL_FILLING_MODE | MT5's flags, as filling_modes spells them out. |
trade_mode | SYMBOL_TRADE_MODE | MT5's value, as trading spells it out. |
execution_mode | SYMBOL_TRADE_EXEMODE | MT5's value, as execution spells it out. |
order_mode | SYMBOL_ORDER_MODE | MT5's flags, as order_types spells them out. |
expiration_mode | SYMBOL_EXPIRATION_MODE | MT5's flags, as expirations spells them out. |
currency_base | SYMBOL_CURRENCY_BASE | |
currency_profit | SYMBOL_CURRENCY_PROFIT | |
currency_margin | SYMBOL_CURRENCY_MARGIN | |
filling_modes | Pipsocket | The type_filling modes MT5's SYMBOL_FILLING_MODE flags allow. |
execution | Pipsocket | MT5's SYMBOL_TRADE_EXEMODE. |
order_types | Pipsocket | The orders the symbol allows (MT5's SYMBOL_ORDER_MODE). |
expirations | Pipsocket | The type_time values the symbol allows (MT5's SYMBOL_EXPIRATION_MODE). |
trading | Pipsocket | MT5's SYMBOL_TRADE_MODE: whether and which way the symbol can be traded. |
A tick (MqlTick):
| API field | MT5 field | Meaning |
|---|
symbol | Pipsocket | |
bid | bid | |
ask | ask | |
time_msc | time_msc | Broker server time, milliseconds since 1970. |
last | last | |
volume | volume_real | |
flags | flags | MT5's TICK_FLAG_* bits: what changed. |