DevCartelGateway64
Built with MT5 gateway API, DevCartelGateway64 accepts connection from MT5 platform and connects to a remote PyMT5 application. It accepts various data types from PyMT5. For complete protocol and documentation, visit PyMT5 GitHub .
Installation
Download a gateway package from our releases
Unzip the package and put the whole folder in MT5 platform's gateway directory e.g. D:\MetaTrader 5 Platform\History\Gateway
Launching
On MT5 Administrator, add a gateway by choosing DevCartelGateway64
Trading server should be an IP address and port of a PyMT5 server application
Click OK and the gateway will establish connection to your PyMT5 application
Gateway Network Protocol
TCP socket.
Message Format
Message is composed of Header+Body+<LF>
where each field in Body
is demilited using ASCII SOH (\x01
) and must be prefixed by the Header
. Each message is ended with ASCII LF (\x0A
), for example:
ver = 3 < SOH > type = 3 < SOH > tag1 = value1 < SOH > tag2 = value2 < SOH > ...< SOH > tagN = valueN < LF >
In this documentation, light vertical bar character (❘
) represents the delimiter ASCII SOH.
Message Type
Login
Tag
Comments
Header
ver=3❘type=1
Body
login
password
res
0
- ok2
- error
Logout
Tag
Comments
Header
ver=3❘type=2
Body
None
Symbol
Tag
Comments
Header
ver=3❘type=3
Body
index
Symbol index
symbol
path
description
source
page
currency_base
currency_profit
currency_margin
digits
tick_flags
calc_mode
exec_mode
chart_mode
fill_flags
expir_flags
tick_value
tick_size
contract_size
volume_min
volume_max
volume_step
market_depth
margin_flags
margin_initial
margin_maintenance
margin_long
margin_short
margin_limit
margin_stop
margin_stop_limit
settlement_price
price_limit_max
price_limit_min
time_start
Trading start date
time_expiration
Trading expiration date
trade_mode
0
- trade disabled1
- only long positions allowed2
- only short positions allowed3
- only position closure4
- all trade operations are allowed
Tick
Tag
Comments
Header
ver=3❘type=4
Body
symbol
bank
bid
ask
last
volume
datetime
POSIX timestamp e.g. 1523278796000
Order
Tag
Comments
Header
ver=3❘type=5
Body
symbol
bank
bid
ask
last
volume
datetime
POSIX timestamp e.g. 1523278796000
order_action
1
- new2
- modify3
- cancel
state
0
- unkonwn1
- confirmed2
- placed3
- new4
- rejected5
- deal6
- modification received7
- modified8
- modification rejected9
- cancelation received10
- canceled11
- cancelation rejected20
- complete
order
MT order ticket
exchange_id
Exchange order ID
custom_data
request_id
symbol
login
MT client login
type_order
0
- buy market1
- sell2
- buy limit3
- sell limit4
- buy stop5
- sell stop6
- buy stop limit7
- sell stop limit
type_time
Expiration0
- good till cancel1
- good till day2
- good till specified3
- good till specified day
type_fill
Filling0
- Return1
- fill or kill2
- immediate or cancel
action
Client action:0
- prices for1
- request2
- instant3
- market4
- exchange5
- pending6
- stop loss/taking profit7
- modify8
- cancel100
- activate101
- activate stop loss102
- activate take profit103
- activate stop-limit order104
- delete stop-out order105
- close stop-out position106
- expire
price_order
price_sl
Stop Loss level
price_tp
Take Profit level
price_tick_bid
Symbol bid price in external trading system
price_tick_ask
Symbol ask price in external trading system
volume
expiration_time
comment
String (32 char max)
position
Position ID
flags
Trade action flags:1
- position close2
- at market price3
- market close
result
Result of order processing:1
- ok10006
- rejected10007
- canceled10008
- placed10009
- complete
Heartbeat
Tag
Comments
Header
ver=3❘type=6
Body
None
Deal
Tag
Comments
Header
ver=3❘type=7
Body
exchange_id
Exchange order ID
order
Order exchange ticket
symbol
login
MT client's login
type_deal
0
- buy1
- sell
volume
Deal volume
volume_rem
Non-filled volume
price
Lot price
Optional
datetime
Deal timestamp
comment
String (32 char max)
position
Position ID
External Deal
Tag
Comments
Header
ver=3❘type=50
Body
exchange_id
Exchange order ID
order
Order exchange ticket
symbol
login
MT client's login
type_deal
0
- buy1
- sell
volume
Deal volume
volume_rem
Non-filled volume
price
Lot price
Optional
datetime
Deal timestamp
comment
String (32 char max)
Support
Changelog
1.9.0
13 May 2022
Support source
in symbol message
1.8.0
7 April 2022
Fix volume
in tick message
Support type_fill
in order message
1.7.0
17 June 2021
Support position
, flags
in order message
1.6.0
1 June 2021
Support comment
in order message
1.5.0
28 May 2021
Support up to 8 decimal for price_order
1.4.0
26 May 2021
Support decimal volume
1.3.0
22 January 2021
Make datetime
in deal message optional
Make comment
in deal message optional
1.2.0
6 August 2020
Supports comment field in external deal
1.1.0
26 April 2018
Supports external deal DatetimeMsc
1.0.0
13 April 2018
Supports login, logout, order, confirm, deal
Supports external deal submission to MT5