Add a Master or a Slave account in your Trade Copier cockpit
URL: https://www.trade-copier.com/webservice/v4/account/addAccount.php
Response: JSON object with the newly added account
Fields noted with a * are optional
| Field Name | Field Type | Field Description |
|---|---|---|
| type | string | 0=Master or 1=Slave |
| name | string | Custom account name |
| broker | string | mt4, mt5, ctrader, fxcm_fc, lmax, dxtrade, fortex or tradovate (always in lower case). For NinjaTrader please use Tradovate |
| login | string | Your broker account login /AccountId (ctidTraderAccountId) for ctrader / Account Number for Tradovate |
| password | string | Your broker account password |
| server | string | MT4: IG-DEMO, FxPro.com-Real02, Ava-Real 1, etc. MT5: ActivTrades-Server, Binary.com-Server, FxPro-MT5, etc. cTrader: write "unknown" LMax Demo: https://web-order.london-demo.lmax.com LMax Live: https://api.lmaxtrader.com FXCM_FC: http://www.fxcorporate.com/Hosts.jsp DXtrade: url of the broker server without https Tradovate/NinjaTrader: write "unknown", see access_token and expiry_token Fortex: url of the broker server without https |
| environment | string | Real or Demo, only for FXCM, LMAX, cTrader and Tradovate/NinjaTrader |
| status | int | The account is 0=disabled, 1=enabled |
| group* | string | One of your existing template's ID. |
| subscription | string | The subscription key of the subscription to assign to your account or "auto", which this automatically selects an available subscription for this account |
| alert_email* | int | Send warning email is 0=disabled, 1=enabled |
| access_token* | string | cTrader and Tradovate Only: The access token that your application will use to authenticate the messages sent to the cTrader Open API. |
| refresh_token* | string | cTrader Only: The refresh token that must be used for renewing the access token once it expires. The refresh token has no expiry time itself. |
| expiry_token* | string | cTrader and Tradovate Only: The number of seconds that must pass before the access token expires (by default, the value of this key equals 2628000). The expiry_token must be "yyyy-mm-dd hh:mm:ss" with timezone CET. |
| client_id* | string | cTrader Only: The unique identifier of your Open API application. Please refer to this link to get your own clientId and Secret Key https://help.ctrader.com/open-api/account-authentication/#attaining-an-access-token |
| client_secret* | string | cTrader Only: The secret key assigned to your Open API application. |
PHP example
<?php
$url="https://www.trade-copier.com/webservice/v4/account/addAccount.php";
$headers = array(
'Content-Type: application/x-www-form-urlencoded',
'Authorization: Bearer [[TOKEN]]',
);
// Open connection
$ch = curl_init();
// Setting the options
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
//We define the template, you can get the existing templates with the "getTemplates.php" webservice
$template = 'DEF';//Template's ID
//$template = null;//No Template
//We define the subscription for the account, you can get available subscriptions with the "getSubscriptions.php" webservice
$subscription = 'auto';//Automaticaly select an available subscription
//$subscription = 'ABCD1234' ;//Subscription's key
//$subscription = null;//No subscription
// Adding data to POST
$account = [
'type' => 1,//0=Master, 1=Slave
'name' => 'name',//Custom name for your account
'broker' => 'mt4',//mt4, mt5, ctrader, lmax, fxcm_fc
'login' => 'login12',
'password' => 'password',
'server' => 'fxpro.com',
'environment' => 'Demo', //Demo, Real
'status' => '0',//The account is 0=disabled, 1=enabled
'group' => $template,//Always an EMPTY string for Master
'subscription' => $subscription,//Always an EMPTY string for Master.
'alert_email' => '0'//0=disabled, 1=enabled
];
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($account));
// Execute request
$json = json_decode(curl_exec($ch));
// Close connection
curl_close($ch);
if(array_key_exists('account', $json))
{
//We access the added account data
echo "New account added: ".$json->account->account_id." ".$json->account->name.
" ".$json->account->login." ".$json->account->server;
}
else
{
//This is an error message that can be access like this:
//echo $json->code." ".$json->error;
echo json_encode($json);
}
?>