The transport format for requests and responses is JSON.
Request objects contain an action
string property, with any params as additional properties.
Response objects contain a response
property.
If the action completed with caveats, the response will contain a warning
property.
If the action failed, the response will contain one or more of the following properties: error_code
, error_code_description
, error_message
.
See MQL4 error codes.
- GET_SYMBOLS
- GET_SYMBOL_INFO
- GET_SYMBOL_MARKET_INFO
- GET_SYMBOL_INFO_INTEGER
- GET_SYMBOL_INFO_DOUBLE
- GET_SYMBOL_INFO_STRING
- GET_SYMBOL_TICK
- GET_OHLCV
- GET_SIGNALS
- GET_SIGNAL_INFO
- RUN_INDICATOR
- GET_ORDER
- GET_ORDERS
- GET_HISTORICAL_ORDERS
- DO_ORDER_SEND
- DO_ORDER_CLOSE
- DO_ORDER_DELETE
- DO_ORDER_MODIFY
Get static information about the account.
{
"action": "GET_ACCOUNT_INFO"
}
{
"response": {
"login": 2102224685,
"name": "my Acme account",
"server": "Acme-Server3",
"currency": "USD",
"company": "Acme, Ltd."
}
}
Get an integer property of the account (see AccountInfoInteger).
property_name
- the ENUM_ACCOUNT_INFO_INTEGER to lookup
{
"action": "GET_ACCOUNT_INFO_INTEGER",
"property_name": "ACCOUNT_LIMIT_ORDERS"
}
{
"response": 1500.0
}
Get a double property of the account (see AccountInfoDouble).
property_name
- the ENUM_ACCOUNT_INFO_DOUBLE property to lookup
{
"action": "GET_ACCOUNT_INFO_DOUBLE",
"property_name": "ACCOUNT_BALANCE"
}
{
"response": 5000.0
}
Get a list of all market symbols available for trading.
{
"action": "GET_SYMBOLS"
}
{
"response": [
"AAPL",
"ADSGn",
"AIG",
"AIRF.PA",
"ALVG",
"AMZN",
"AUDCAD",
"AUDCHF",
...
]
}
Get static information about the given market symbols.
names
- a list of symbol names
{
"action": "GET_SYMBOL_INFO",
"names": [
"EURUSD",
"USDJPY"
]
}
{
"response": {
"EURUSD": {
"digits": 5,
"name": "EURUSD",
"point": 1e-05,
"trade_contract_size": 100000.0,
"trade_freeze_level": 0,
"trade_stops_level": 0,
"trade_tick_size": 1e-05,
"trade_tick_value": 1.0,
"volume_max": 1000.0,
"volume_min": 0.01,
"volume_step": 0.01
},
"USDJPY": {
"digits": 3,
"name": "USDJPY",
"point": 0.001,
"trade_contract_size": 100000.0,
"trade_freeze_level": 0,
"trade_stops_level": 0,
"trade_tick_size": 0.001,
"trade_tick_value": 0.9499924,
"volume_max": 1000.0,
"volume_min": 0.01,
"volume_step": 0.01
}
}
}
Get market information about the given symbol (see MarketInfo).
symbol
- the market symbolproperty
- the symbol property to lookup
{
"action": "GET_SYMBOL_MARKET_INFO",
"symbol": "EURUSD",
"property": "MODE_BID"
}
{
"response": 1.13006
}
Get an integer property of a symbol (see SymbolInfoInteger).
symbol
- the market symbolproperty_name
- the ENUM_SYMBOL_INFO_INTEGER to lookup
{
"action": "GET_SYMBOL_INFO_INTEGER",
"symbol": "EURUSD",
"property_name": "SYMBOL_SELECT"
}
{
"response": 1
}
Get a double property of a symbol (see SymbolInfoDouble).
symbol
- the market symbolproperty_name
- the ENUM_SYMBOL_INFO_DOUBLE to lookup
{
"action": "GET_SYMBOL_INFO_DOUBLE",
"symbol": "EURUSD",
"property_name": "SYMBOL_BID"
}
{
"response": 1.13247
}
Get a string property of a symbol (see SymbolInfoString).
symbol
- the market symbolproperty_name
- the ENUM_SYMBOL_INFO_STRING to lookup
{
"action": "GET_SYMBOL_INFO_STRING",
"symbol": "EURUSD",
"property_name": "SYMBOL_CURRENCY_BASE"
}
{
"response": "EUR"
}
Get the current prices of the given symbol (see SymbolInfoTick).
symbol
- the market symbol
{
"action": "GET_SYMBOL_TICK",
"symbol": "EURUSD"
}
{
"response": {
"ask": 1.13346,
"bid": 1.13338,
"last": 0.0,
"time": 1591744136,
"volume": 0
}
}
Get the most recent OHLCV bars for the given symbol.
symbol
- the market symboltimeframe
- the width of the bars, in minutes. Use a standard timeframe for a better chance of the broker's server responding successfully.limit
- the maximum number of bars to returntimeout
- the timeout in milliseconds to wait for the broker's server to return the data
{
"action": "GET_OHLCV",
"symbol": "EURUSD",
"timeframe": 60,
"limit": 100,
"timeout": 5000
}
{
"response": [
{
"open": 1.12307,
"high": 1.124,
"low": 1.12301,
"close": 1.12372,
"tick_volume": 1702,
"time": 1592424000
},
{
"open": 1.12372,
"high": 1.12372,
"low": 1.12294,
"close": 1.12308,
"tick_volume": 1468,
"time": 1592427600
},
...
]
}
Get a list of all trade signals available in the terminal.
{
"action": "GET_SIGNALS"
}
{
"response": [
"FibonacciBreakout",
"EA Happy Gold",
"Batman EA",
"EA Happy Market Hours",
"EA Red Dragon l Demo FXCC l",
"EA Skynet l Demo FXCC l",
...
}
Get detailed information on one or more trading signals.
names
- a list of signal names
{
"action": "GET_SIGNAL_INFO",
"names": [
"EA Happy Gold",
"FibonacciBreakout"
]
}
{
"response": {
"EA Happy Gold": {
"author_login": "HappyForex",
"balance": 220230.23,
"broker": "TF Global Markets (Aust) Pty Ltd",
"broker_server": "ThinkForexAU-Demo",
"currency": "USD",
"date_published": 1396947432,
"date_started": 1396940232,
"equity": 220230.23,
"gain": 21923.02,
"id": 36094,
"leverage": 400,
"max_drawdown": 21.98,
"name": "EA Happy Gold",
"pips": 41114,
"price": 20.0,
"rating": 46,
"roi": 21923.02,
"subscribers": 0,
"trade_mode": 1,
"trades": 1443
},
"FibonacciBreakout": {
"author_login": "Antonov-EA",
"balance": 21522.68,
...
}
}
}
Run one of the built-in technical indicator functions. If data is requested that is not already loaded in the terminal, it must be loaded from the broker server, which is why a timeout must be specified.
indicator
- the name of the indicator functionargv
- a list of indicator function parameterstimeout
- the timeout in milliseconds
{
"action": "RUN_INDICATOR",
"indicator": "iAC",
"argv": ["EURUSD", 60, 1],
"timeout": 5000
}
{
"response": 2.251e-05
}
Lookup an open, pending, or closed order using its ticket number.
ticket
- the ticket number of the order
{
"action": "GET_ORDER",
"ticket": 121204376
}
{
"response": {
"close_price": 1.13668,
"close_time": "1970.01.01 00:00:00",
"comment": null,
"commission": -0.04,
"expiration": "1970.01.01 00:00:00",
"lots": 0.01,
"magic_number": 0,
"open_price": 1.13672,
"open_time": "2020.06.10 23:30:32",
"order_type": 0,
"profit": -0.04,
"sl": 0.0,
"swap": 0.0,
"symbol": "EURUSD",
"ticket": 121204376,
"tp": 0.0
}
}
Lookup all market and pending orders.
{
"action": "GET_ORDERS"
}
{
"response": [
{
"close_price": 1.13668,
"close_time": "1970.01.01 00:00:00",
"comment": null,
"commission": -0.04,
"expiration": "1970.01.01 00:00:00",
"lots": 0.01,
"magic_number": 0,
"open_price": 1.13672,
"open_time": "2020.06.10 23:30:32",
"order_type": 0,
"profit": -0.04,
"sl": 0.0,
"swap": 0.0,
"symbol": "EURUSD",
"ticket": 121204376,
"tp": 0.0
}, {
"close_price": 1.13671,
...
}
]
}
Lookup all closed orders loaded in the "Account History" tab of the MT4 terminal.
{
"action": "GET_HISTORICAL_ORDERS"
}
{
"response": [
{
"close_price": 1.13672,
"close_time": "2020.06.10 23:29:57",
"comment": null,
"commission": -0.04,
"expiration": "1970.01.01 00:00:00",
"lots": 0.01,
"magic_number": 0,
"open_price": 1.13665,
"open_time": "2020.06.10 23:29:42",
"order_type": 1,
"profit": -0.07,
"sl": 0.0,
"swap": 0.0,
"symbol": "EURUSD",
"ticket": 121204101,
"tp": 0.0
},
{
"close_price": 0.0,
...
}
]
}
Open a market order or place a pending order. This action is more than just a wrapper around the OrderSend() function. If stop-loss or take-profit params are specified, the order is opened with the given price and then modified with those values (in order to comply with the ECN trading protocol). If the values violate the trading requirements and limitations, they are nudged the minimum amount to allow the modification to take place. The resulting order is returned.
symbol
- the market symbolorder_type
- the order type. Must be an integer value from the order properties tablelots
- the number of lots to tradeprice
- the desired open price. Required for pending orders, but can be omitted for market ordersslippage
- the maximum price slippage, in points. Omit to use a permissive default (2x the market spread)sl
- the absolute stop-losssl_points
- the relative stop-loss (mutually exclusive withsl
)tp
- the absolute take-profittp_points
- the relative take-profit (mutually exclusive withtp
)comment
- a string comment to attach to the order
{
"action": "DO_ORDER_SEND",
"symbol": "EURUSD",
"order_type": 0,
"lots": 1,
"comment": "This is a market buy order."
}
{
"response": {
"close_price": 1.12523,
"close_time": "1970.01.01 00:00:00",
"comment": "This is a market buy order.",
"commission": -4.0,
"expiration": "1970.01.01 00:00:00",
"lots": 1.0,
"magic_number": 0,
"open_price": 1.1253,
"open_time": "2020.06.25 04:50:17",
"order_type": 0,
"profit": -7.0,
"sl": 0.0,
"swap": 0.0,
"symbol": "EURUSD",
"ticket": 124114600,
"tp": 0.0
}
}
Close an opened order.
ticket
- the ticket number of the orderlots
- the number of lots. Omit to close entire orderprice
- the closing price. Omit to close at market priceslippage
- the maximum price slippage, in points. Omit to use a permissive default (2x the market spread)
{
"action": "DO_ORDER_CLOSE",
"ticket": 124114600
}
{
"response": "Closed order # 124114600"
}
Delete a pending order.
ticket
- the ticket number of the ordercloseIfOpened
- if true and the order is open, it is closed at market price. Defaults tofalse
.
{
"action": "DO_ORDER_DELETE",
"ticket": 124114600
}
{
"response": "Deleted pending order # 124114600"
}
Modify a previously opened or pending order.
ticket
- the ticket number of the orderprice
- the new open price of the pending ordersl
- the absolute stop-losssl_points
- the relative stop-loss (mutually exclusive withsl
)tp
- the absolute take-profittp_points
- the relative take-profit (mutually exclusive withtp
)
{
"action": "DO_ORDER_MODIFY",
"ticket": 124114600,
"price": 1.13552
}
{
"response": {
"close_price": 1.13552,
"close_time": "1970.01.01 00:00:00",
"comment": "This is a pending order.",
"commission": -4.0,
"expiration": "1970.01.01 00:00:00",
"lots": 1.0,
"magic_number": 0,
"open_price": 1.13552,
"open_time": "2020.06.25 04:50:17",
"order_type": 0,
"profit": -7.0,
"sl": 0.0,
"swap": 0.0,
"symbol": "EURUSD",
"ticket": 124114600,
"tp": 0.0
}
}