Skip to content

๐Ÿ“˜ API Reference โ€” Messages (MT5)

This page documents message types used by the MT5 gRPC API (mt5_term_api). Numbers, names and field order match the source .proto files. Enums are listed in the Enums (MT5) page.


๐Ÿ”– Conventions

  • google.protobuf.Timestamp โ†’ โฐ UTC time.
  • optional fields โ†’ present only when explicitly set (proto3 optional).
  • Wrappers โ†’ the API mostly uses plain primitives; when wrappers appear, they provide presence.
  • Prices & volumes โ†’ ๐Ÿ’น validate with SymbolInfoDoubleProperty (e.g., SymbolVolumeMin/Max/Step).
  • Currency โ†’ ๐Ÿ’ต monetary values are in account currency (see AccountSummaryData.account_currency).

๐Ÿงพ Account & Orders

๐Ÿ“Š AccountSummary (AccountSummaryData)

# Field Type
1 account_login int64
2 account_balance double
3 account_equity double
4 account_user_name string
5 account_leverage int64
6 account_trade_mode MrpcEnumAccountTradeMode
7 account_company_name string
8 account_currency string
9 server_time Timestamp
10 utc_timezone_server_time_shift_minutes int64
11 account_credit double

Notes: snapshot for health/risk checks; leverage as integer; server_time is UTC.


๐Ÿ“Œ OpenedOrderInfo (live orders/pending)

# Field Type
1 index uint32
2 ticket uint64
3 price_current double
4 price_open double
5 stop_limit double
6 stop_loss double
7 take_profit double
8 volume_current double
9 volume_initial double
10 magic_number int64
11 reason int32
12 type BMT5_ENUM_ORDER_TYPE
13 state BMT5_ENUM_ORDER_STATE
14 time_expiration Timestamp
15 time_setup Timestamp
16 time_done Timestamp
17 type_filling BMT5_ENUM_ORDER_TYPE_FILLING
18 type_time BMT5_ENUM_ORDER_TYPE_TIME
19 position_id int64
20 position_by_id int64
21 symbol string
22 external_id string
23 comment string
24 account_login int64

Notes: used in OpenedOrders{Request,Reply,Data}.


๐Ÿ“Œ PositionInfo (open positions)

# Field Type
1 index uint32
2 ticket uint64
3 open_time Timestamp
4 volume double
5 price_open double
6 stop_loss double
7 take_profit double
8 price_current double
9 swap double
10 profit double
11 last_update_time Timestamp
12 type BMT5_ENUM_POSITION_TYPE
13 magic_number int64
14 identifier int64
15 reason BMT5_ENUM_POSITION_REASON
16 symbol string
17 comment string
18 external_id string
19 position_commission double
20 account_login int64

๐Ÿ“จ OrderSendRequest / OrderSendReply / OrderSendData

OrderSendRequest

# Field Type Optional
1 symbol string
2 operation TMT5_ENUM_ORDER_TYPE
3 volume double
4 price double โœ“
5 slippage uint64 โœ“
6 stop_loss double โœ“
7 take_profit double โœ“
8 comment string โœ“
9 expert_id uint64 โœ“
10 stop_limit_price double โœ“
11 expiration_time_type TMT5_ENUM_ORDER_TYPE_TIME โœ“
12 expiration_time Timestamp โœ“

OrderSendReply

# Field Type
1 data OrderSendData
2 error Error

OrderSendData

# Field Type
1 returned_code uint32
2 deal uint64
3 order uint64
4 volume double
5 price double
6 bid double
7 ask double
8 comment string
9 request_id uint32
10 ret_code_external int32
11 returned_string_code string
12 returned_code_description string

โœ๏ธ OrderModifyRequest / OrderModifyReply / OrderModifyData

OrderModifyRequest

# Field Type Optional
1 ticket uint64
2 stop_loss double โœ“
3 take_profit double โœ“
4 price double โœ“
5 expiration_time_type TMT5_ENUM_ORDER_TYPE_TIME โœ“
6 expiration_time Timestamp โœ“
8 stop_limit double โœ“

OrderModifyReply

# Field Type
1 data OrderModifyData
2 error Error

OrderModifyData โ€” same shape as OrderSendData (fields 1..12).


โŒ OrderCloseRequest / OrderCloseReply / OrderCloseData

OrderCloseRequest

# Field Type
1 ticket uint64
2 volume double
5 slippage int32

OrderCloseReply

# Field Type
1 data OrderCloseData
2 error Error

OrderCloseData

# Field Type
1 returned_code uint32
2 returned_string_code string
3 returned_code_description string
4 close_mode MRPC_ORDER_CLOSE_MODE

๐Ÿ’น Quotes & Market Info

๐Ÿ’ฑ MrpcMqlTick (tick)

# Field Type
1 time int64
2 bid double
3 ask double
4 last double
5 volume uint64
6 time_msc int64
7 flags uint32
8 volume_real double

Notes: spread in points = (ask - bid) / Symbol.Point.


๐Ÿ”Ž SymbolInfoDouble{Request,Reply,Data}

SymbolInfoDoubleRequest

# Field Type
1 symbol string
2 type SymbolInfoDoubleProperty

SymbolInfoDoubleReply โ€” oneof { data (SymbolInfoDoubleData = 1), error (Error = 2) }

SymbolInfoDoubleData

# Field Type
1 value double

๐Ÿ“Œ SymbolSelect{Request,Reply,Data}

SymbolSelectRequest

# Field Type
1 symbol string
2 select bool

SymbolSelectReply โ€” oneof { data (SymbolSelectData = 1), error (Error = 2) }

SymbolSelectData

# Field Type
1 success bool

๐Ÿ”„ SymbolIsSynchronized{Request,Reply,Data}

SymbolIsSynchronizedRequest

# Field Type
1 symbol string

SymbolIsSynchronizedReply โ€” oneof { data (SymbolIsSynchronizedData = 1), error (Error = 2) }

SymbolIsSynchronizedData

# Field Type
1 synchronized bool

#๏ธโƒฃ SymbolsTotal{Request,Reply,Data}

SymbolsTotalRequest

# Field Type
1 mode bool

SymbolsTotalReply โ€” oneof { data (SymbolsTotalData = 1), error (Error = 2) }

SymbolsTotalData

# Field Type
1 total int32

๐Ÿ”Œ Connection & Health

๐Ÿ” Connection.ConnectEx / Connect

ConnectExRequest

# Field Type
1 user uint64
2 password string
3 mt_cluster_name string
4 base_chart_symbol string
5 terminal_readiness_waiting_timeout_seconds int32
6 experts_to_add ExpertAdviser (repeated)

ConnectExReply โ€” oneof { data (ConnectData = 1), error (Error = 2) }

ConnectRequest

# Field Type
1 user uint64
2 password string
3 host string
4 port int32
5 base_chart_symbol string
6 wait_for_terminal_is_alive bool
7 terminal_readiness_waiting_timeout_seconds int32
8 experts_to_add ExpertAdviser (repeated)

ConnectReply โ€” oneof { data (ConnectData = 1), error (Error = 2) }

ConnectData

# Field Type
1 terminal_instance_guid string
3 terminal_type TerminalType

DisconnectRequest โ€” (empty)

DisconnectReply โ€” oneof { data (DisconnectData = 1), error (Error = 2) }

DisconnectData

# Field Type
1 unique_identifier string
2 full_life_time_seconds int64

Health.Check

HealthCheckRequest โ€” (empty)

HealthCheckReply

# Field Type
1 is_connected_to_server bool
2 server_time_seconds int64

๐Ÿ“ก Streaming payload helpers (overview)

Detailed stream methods & chunk types are in the Streaming (MT5) page.

  • Quotes: OnSymbolTick{Request,Reply,Data} with MrpcSubscriptionMqlTick.
  • Trades: OnTrade{Request,Reply,Data} with OnTadeEventData (new/disappeared/updated orders, deals, positions).
  • Position PnL snapshots: OnPositionProfit{Request,Reply,Data}.
  • Tickets stream: OnPositionsAndPendingOrdersTickets{Request,Reply}.

๐Ÿ“Œ Tip: When building requests, use the correct enums for fields (e.g., TMT5_ENUM_ORDER_TYPE, TMT5_ENUM_ORDER_TYPE_TIME). Validate volumes (SymbolVolumeMin/Max/Step) and prices (broker Stops/Freeze levels) to avoid rejections.