DevCartel MT5 gateway for MetaTrader 5 Platform
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.
D:\MetaTrader 5 Platform\History\Gateway
TCP socket.
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.
Tag | Comments |
---|---|
Header | ver=3❘type=1 |
Body | |
login |
|
password |
|
res |
0 - ok2 - error |
Tag | Comments |
---|---|
Header | ver=3❘type=2 |
Body | None |
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 |
Tag | Comments |
---|---|
Header | ver=3❘type=4 |
Body | |
symbol |
|
bank |
|
bid |
|
ask |
|
last |
|
volume |
|
datetime |
POSIX timestamp e.g. 1523278796000 |
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 |
Tag | Comments |
---|---|
Header | ver=3❘type=6 |
Body | None |
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 |
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) |
1.9.0
source
in symbol message1.8.0
volume
in tick messagetype_fill
in order message1.7.0
position
, flags
in order message1.6.0
comment
in order message1.5.0
price_order
1.4.0
volume
1.3.0
datetime
in deal message optionalcomment
in deal message optional1.2.0
1.1.0
1.0.0