Forex Trading Tools - MT4 Web API
Forex Trading Tools - MT4 Web API
WCF RESTFUL
Contents
1 Introduction .......................................................................................................................................... 4
2 How to Use ............................................................................................................................................ 4
3 Webservice Reference .......................................................................................................................... 4
3.1 Authenticate User ......................................................................................................................... 4
3.1.1 Inputs .................................................................................................................................... 4
3.1.2 Output ................................................................................................................................... 4
3.2 CreateAccount .............................................................................................................................. 4
3.2.1 Inputs .................................................................................................................................... 4
2.1.2 Output ................................................................................................................................... 6
3.3 ModifyAccount.............................................................................................................................. 6
3.3.1 Inputs .................................................................................................................................... 6
3.3.2 Output ................................................................................................................................... 7
3.4 GetAccounts .................................................................................................................................. 8
3.4.1 Inputs .................................................................................................................................... 8
3.4.2 Output ................................................................................................................................... 8
3.5 GetAccountInfo ............................................................................................................................. 8
3.5.1 Inputs .................................................................................................................................... 8
3.5.2 Output ................................................................................................................................... 8
3.6 CheckPassword ............................................................................................................................. 9
3.6.1 Inputs .................................................................................................................................... 9
3.6.2 Output ................................................................................................................................... 9
3.7 ChangePassword ........................................................................................................................... 9
3.7.1 Inputs .................................................................................................................................... 9
3.7.2 Output ................................................................................................................................. 10
3.8 GetAccountBalance ..................................................................................................................... 10
3.8.1 Inputs .................................................................................................................................. 10
3.8.2 Output ................................................................................................................................. 10
3.9 ChangeBalance ............................................................................................................................ 10
3.9.1 Inputs .................................................................................................................................. 11
3.9.2 Output ................................................................................................................................. 11
3.10 ChangeCredit............................................................................................................................... 11
2 How to Use
Authenticate the user by passing the correct username and the password. If the username and
password is valid we generate the taken id. The username and password is provided by us.
The generated token id can be used to pass in every function.
The particular session would be available for only 20 minutes after that the session got expired
and the user needs to login again.
3 Webservice Reference
The web service URL is the URL where the web services are installed.
3.1.1 Inputs
SNo Name Desc Type
3.1.2 Output
The Output is in the JSON format like
1045789231411:55:02
3.2 CreateAccount
To create trader Account.
3.2.1 Inputs
SNo Name Desc Type
2.1.2 Output
The output is in form of JSON format with following description.
1. "OK/None"
2. "Invalid parameters",
3. "Network problem",
4. "Common Error
1. Login Id
2. Password
3. Investor Password
3.3 ModifyAccount
To modify Trader account.
3.3.1 Inputs
SNo Name Desc Type
3.3.2 Output
The output is in form of JSON format with following description.
1. "OK"
3.4 GetAccounts
Get trader account details of manager.
3.4.1 Inputs
None
e.g. "1,GetAccounts"
Here 1 is SERVERNAME.
3.4.2 Output
The output is in form of JSON format with following description.
1. {"Accounts":[{"address":"","balance":15141.66,"city":"","country":"United
States","credit":0,"email":"","group":"TSTRADE1","leverage":100,"login":18138,"name":"Bhaskar
Roy","phone":"","regdate":1454398356,"state":"","zipcode":""},{"address":"","balance":23607.3
4,"city":"","country":"United
States","credit":0,"email":"","group":"TSTRADE1","leverage":100,"login":18141,"name":"Master
1","phone":"","regdate":1454406970,"state":"","zipcode":""}],"TotalAccounts":2,"isLast":0,"mess
age":"OK","msgtype":79,"result":0}
3.5 GetAccountInfo
To get account information of a trader.
3.5.1 Inputs
SNo Name Desc Type
3.5.2 Output
The output is in form of JSON format with following description.
1. "Network problem",
2. "Common Error
1. Login
2. Balance
3. Phone
4. Email
5. Address
6. City
7. State
8. Country
3.6 CheckPassword
To verify trader password.
3.6.1 Inputs
SNo Name Desc Type
3.6.2 Output
The output is in form of JSON format with following description.
1. "OK/None"
2. "Invalid parameters",
3. "Network problem",
4. "Common Error
1. "OK"
3.7 ChangePassword
To change password of trader account.
3.7.1 Inputs
SNo Name Desc Type
3.7.2 Output
The output is in form of JSON format with following description.
1. "OK/None"
2. "Invalid parameters",
3. "Network problem",
4. "Common Error
1. "OK"
3.8 GetAccountBalance
To get trader account balance.
3.8.1 Inputs
SNo Name Desc Type
3.8.2 Output
The output is in form of JSON format with following description.
1. "Network problem",
2. "Common Error
3. "Invalid Account No."
1. Balance
3.9 ChangeBalance
To change trader account balance.
3.9.2 Output
The output is in form of JSON format with following description.
1. "OK/None"
2. "Invalid parameters",
3. "Network problem",
4. "Common Error
1. "OK"
3.10 ChangeCredit
To change trader credit amount.
3.10.1 Inputs
SNo Name Desc Type
3.10.2 Output
The output is in form of JSON format with following description.
1. "OK/None"
2. "Invalid parameters",
3. "Network problem",
4. "Common Error
3.11 GetGroups
To get all groups of manager account.
3.11.1 Inputs
None.
e.g. "1,GetGroups,"
Here 1 is SERVERNAME.
3.11.2 Output
The output is in form of JSON format with following description.
Response JSON :
In case of isLast is 0,
there will be more
response still coming
from server.
Groups:
e.g.
{"Groups":[{"credit":0,"currency":"USD","default_leverage":100,"group":"TSTRADE1"},{"credit":0,"curre
ncy":"USD","default_leverage":100,"group":"TSTRADE2"},{"credit":0,"currency":"","default_leverage":0,
"group":"manager"}],"TotalGroups":3,"isLast":1,"message":"OK","msgtype":83,"result":0}
3.12 GetGroupRecord
To get group record of a trader.
3.12.1 Inputs
SNo Name Desc Type
e.g. "1,GetGroupRecord,TSTRADE2";
3.12.2 Output
The output is in form of JSON format with following description.
Response JSON :
In case of isLast is 0,
there will be more
response still coming
from server.
Groups:
e.g.
{"Groups":[{"credit":0,"currency":"USD","default_leverage":100,"group":"TSTRADE1"},{"credit":0,"curre
ncy":"USD","default_leverage":100,"group":"TSTRADE2"},{"credit":0,"currency":"","default_leverage":0,
"group":"manager"}],"TotalGroups":3,"isLast":1,"message":"OK","msgtype":83,"result":0}
3.13 GetTradeHistory
To get history of trades of trader acoount.
3.13.1 Inputs
SNo Name Desc Type
3.13.2 Output
The output is in form of JSON format with following description.
1. "Network problem",
2. "Common Error
1. order
2. open_time
3. Open_price
4. close_time
5. close_price
3.14 GetJournal
To get journals of manager.
3.14.1 Inputs
SNo Name Desc Type
e.g."Standard","Logins","Trades","Errors","Full",
"LiveUpdate","SendMail","Failover"
2 FromTime Date Unix TimeStamp
3.14.2 Output
The output is in form of JSON format with following description.
1. "Network problem",
2. "Common Error
1. code
3.15.1 Inputs
SNo Name Desc Type
3.15.2 Output
The output is in form of JSON format with following description.
1. "Network problem",
2. "Common Error
1. margin_call
2. margin_mode
3. margin_stopout
4. margin_type
3.16 GetOpenOrders
To get all open trades of manager.
3.16.1 Inputs
None
3.16.2 Output
The output is in form of JSON format with following description.
1. "Network problem",
2. "Common Error
1. order
2. Login
3. Symbol
4. Digits
5. Cmd
6. Volume
3.17.1 Inputs
None
3.17.2 Output
The output is in form of JSON format with following description.
1. "Network problem",
2. "Common Error
1. Symbol
2. Description
3. source
4. currency
5. type
6. digits
7. trade
3.18 OpenOrder
To open a new market order by trader.
3.18.1 Inputs
SNo Name Desc Type
13 crc int
3.18.2 Output
The output is in form of JSON format with following description.
1. "OK/None"
2. "Invalid parameters",
3. "Network problem",
4. "Common Error
1. "Order"
3.19 ModifyOrder
To modify an open order of trader.
3.19.1 Inputs
SNo Name Desc Type
13 crc int
3.19.2 Output
The output is in form of JSON format with following description.
1. "OK/None"
2. "Invalid parameters",
3. "Network problem",
4. "Common Error
1. "OK"
3.20 OpenPendingOrder
To open a new pending order of trader.
3.20.1 Inputs
SNo Name Desc Type
14 crc int
3.20.2 Output
The output is in form of JSON format with following description.
1. "OK/None"
2. "Invalid parameters",
3. "Network problem",
4. "Common Error
1. "Order"
3.21 ModifyPendingOrder
To modify an open pending order of trader.
14 crc int
3.21.2 Output
The output is in form of JSON format with following description.
1. "OK/None"
2. "Invalid parameters",
3. "Network problem",
4. "Common Error
1. "OK"
3.22.1 Inputs
SNo Name Desc Type
9 sl stoploss double
10 tp takeprofit double
13 crc int
3.22.2 Output
The output is in form of JSON format with following description.
1. "OK/None"
2. "Invalid parameters",
3. "Network problem",
4. "Common Error
1. "OK"
3.23.1 Inputs
SNo Name Desc Type
9 sl stoploss double
10 tp takeprofit double
13 crc int
3.23.2 Output
The output is in form of JSON format with following description.
1. "OK/None"
2. "Invalid parameters",
3. "Network problem",
4. "Common Error
1. "OK"
3.24.1 Inputs
SNo Name Desc Type
3.24.2 Output
The output is in form of JSON format with following description.
1. "OK/None"
2. "Invalid parameters",
3. "Network problem",
4. "Common Error
1. "OK"
3.25 TransferBalance
To transfer balance from one trader account to another.
3.25.1 Inputs
SNo Name Desc Type
3.25.2 Output
The output is in form of JSON format with following description.
1. "OK"
3.26 GetLeverageOfGroup
To get leverage of a group.
3.26.1 Inputs
SNo Name Desc Type
3.26.2 Output
The output is in form of JSON format with following description.
1. "Network problem",
2. "Invalid Group"
3. "Common Error
1. Leverage
3.27 GetAllLeverage
To get leverage of all groups
3.27.1 Inputs
None
3.27.2 Output
The output is in form of JSON format with following description.
1. "Network problem",
2. "Invalid Group"
3. "Common Error
3.28 AccountHaveTrades
accountId,GroupName
4 Service Calls
GetAccounts(string tokenid, int managerId);
UriTemplate = "GetAccounts/{tokenid}/{managerId}"
CheckPassword(string tokenid, int managerId, int accountId, string password, string comment);
ChangePassword(string tokenid, int managerId, int accountId, string password, string newpassword);
changeBalance(string tokenid, int managerId, int accountId, double balance, string comment);
ChangeCredit(string tokenid, int managerId, int accountId, double balance, string time, string
comment)
UriTemplate =
"TransferBalance/{tokenid}/{managerId}/{fromaccountId}/{ToaccountId}/{balance}/{comment}""
UriTemplate = "GetAccounts/{tokenid}/{managerId}"
CreateAccount(string tokenid, int managerId, int login, string group, string password, int enable,
UriTemplate = "
CreateAccount/{tokenid}/{managerId}/{login}/{group}/"{password}/{enable}/{enable_change_password
}/{enable_read_only}/{password_investor}/{password_phone}/{name}/{country}/{city}/{state}/{zipcode}
/{address}/{phone}/{email}/{id}/{status}/{leverage}/{agent_account}/{balance}/{prevmonthbalance}/{pr
evbalance}/{credit}/{interestrate}}/{taxes}/{prevmonthequity}/{prevequity}/{publickey}/{send_reports}/
{mqid}"
UriTemplate = "
ModifyAccount/{tokenid}/{managerId}/{login}/{group}/{password}/{enable}/{enable_change_password}
/{enable_read_only}/{password_investor}/{password_phone}/{name}/{country}/{city}/{state}/{zipcode}
/{address}/{phone}/{email}/{id}/{status}/{leverage}/{agent_account}/{balance}/{prevmonthbalance}/{pr
evbalance}/{credit}/{interestrate}}/{taxes}/{prevmonthequity}/{prevequity}/{publickey}/{send_reports}/
{mqid}"
OpenOrder(string tokenid, int managerId, char Type, char reserved, short cmd, int order, int LoginId,
string symbol, int volume, double tradeprice, double stoploss, double takeprofit, int deviation,
string comment, int crc);
UriTemplate = "
OpenOrder/{tokenid}/{managerId}/{Type}/{reserved}/{cmd}/{order}/{LoginId}/{symbol}/{volume}/{trade
price}/{stoploss}/{takeprofit}/{deviation}/{comment}/{crc}"
ModifyOrder(string tokenid, int managerId, char Type, char reserved, short cmd, int order, int LoginId,
string symbol, int volume, double tradeprice, double stoploss, double takeprofit, int deviation,
string comment, int crc);
UriTemplate = "
ModifyOrder/{tokenid}/{managerId}/{Type}/{reserved}/{cmd}/{order}/{LoginId}/{symbol}/{volume}/{tra
deprice}/{stoploss}/{takeprofit}/{deviation}/{comment}/{crc}"
UriTemplate =
OpenPendingOrder
/{tokenid}/{managerId}/{Type}/{reserved}/{cmd}/{order}/{LoginId}/{symbol}/{volume}/{tradeprice}/{sto
ploss}/{takeprofit}/{deviation}/{comment}}/{expiration}/{crc}"
ModifyPendingOrder (string tokenid, int managerId, char Type, char reserved, short cmd, int order, int
LoginId, string symbol, int volume, double tradeprice, double stoploss, double takeprofit, int
deviation, string comment, string expiration, int crc);
UriTemplate =
ModifyPendingOrder
/{tokenid}/{managerId}/{Type}/{reserved}/{cmd}/{order}/{LoginId}/{symbol}/{volume}/{tradeprice}/{sto
ploss}/{takeprofit}/{deviation}/{comment}}/{expiration}/{crc}"
CloseOrder (string tokenid, int managerId, char Type, char reserved, short cmd, int order, int LoginId,
string symbol, int volume, double tradeprice, double stoploss, double takeprofit, int deviation,
string comment, int crc);
UriTemplate = "
CloseOrder/{tokenid}/{managerId}/{Type}/{reserved}/{cmd}/{order}/{LoginId}/{symbol}/{volume}/{trade
price}/{stoploss}/{takeprofit}/{deviation}/{comment}/{crc}"
DeleteOrder (string tokenid, int managerId, char Type, char reserved, short cmd, int order, int LoginId,
string symbol, int volume, double tradeprice, double stoploss, double takeprofit, int deviation,
string comment, int crc);
UriTemplate = "
DeleteOrder/{tokenid}/{managerId}/{Type}/{reserved}/{cmd}/{order}/{LoginId}/{symbol}/{volume}/{trad
eprice}/{stoploss}/{takeprofit}/{deviation}/{comment}/{crc}"