Client RESTful API for MT4 Servers
Full functional trial version for 14 days. More details and full version available at:
- Main website: https://mtapi.io
- Demo environment and documentation: https://mt4.mtapi.io
- Postman RESTful
- Postman Websockets
Connect to MT4 Server
To establish connection with MT4 Server use Connect endpoint. It requires broker host, port, mt4 account number and password.
https://mt4.mtapi.io/Connect?user=500476959&password=ehj4bod&host=mt4-demo.roboforex.com&port=443
It returns token that you need to use as 'id' parameter in further requests to server.
Account details
If you need Balance, Equity, Currency, FreeMargin etc. please use AccountSummary endpoint.
https://mt4.mtapi.io/AccountSummary?id=demo-token-mt4
Trading
To send different types of orders use OrderSend endpoint.
-
Market order: https://mt4.mtapi.io/OrderSend?id=demo-token-mt4&symbol=EURUSD&operation=Buy&volume=0.01
-
Stop order: https://mt4.mtapi.io/OrderSend?id=demo-token-mt4&symbol=EURUSD&operation=BuyStop&volume=0.01&price=1.5
-
Limit order: https://mt4.mtapi.io/OrderSend?id=demo-token-mt4&symbol=EURUSD&operation=BuyLimit&volume=0.01&price=0.5
Order history
Use OrderHistory endpoint to get list of closed orders.
Opened orders
To get list of active market and pending orders use OpenedOrders endpoint.
https://mt4.mtapi.io/OpenedOrders?id=demo-token-mt4
It returns array of orders.
Quote history
To get OHLC price history please use QuoteHistory endpoint.
It returns array of bars.
Trading instruments
To get list of trading instruments please use Symbols endpoint.
https://mt4.mtapi.io/Symbols?id=demo-token-mt4
To get details of certain symbol use SymbolParams endpoint.
https://mt4.mtapi.io/SymbolParams?id=demo-token-mt4&symbol=EURUSD
Realtime quotes with websockets
-
Call /Connect method to get identification token.
-
In websocket test client open link like this wss://mt4.mtapi.io/events?id=demo-token-mt4 where “id” parameter is identification token from previous step.
Simple Web Socket test client for chrome browser: https://chrome.google.com/webstore/detail/websocket-test-client/fgponpodhbmadfljofbimhhlengambbn
- Call /Subscribe method
- Quotes should start to flow in websocket test client