Define global protection for a slave account
URL: https://www.trade-copier.com/webservice/v4/protection/setGlobalProtection.php
Response: JSON object with success or error message
Fields noted with a * are optional
| Field Name | Field Type | Field Description |
|---|---|---|
| slave_id | string | Encrypted slave account ID |
| global_take_profit* | integer | Enable or disable global take profit mode (0-7) |
| global_take_profit_type* | integer | Global take profit calculation type (0=Close Only, 1= Close All and Disable Copy, 2= Disable Copy) |
| global_take_profit_value* | float | Global take profit threshold value |
| daily_take_profit* | integer | Enable or disable daily take profit mode (0-7) |
| daily_take_profit_type* | integer | Daily take profit calculation type (0=Close Only, 1= Close All and Disable Copy, 2= Disable Copy) |
| daily_take_profit_value* | float | Daily take profit threshold value |
| global_stop_loss | integer | Enable or disable global stop loss mode (0-7) |
| global_stop_loss_type* | integer | Global stop loss calculation type (0=Close Only, 1= Close All and Disable Copy, 2= Disable Copy) |
| global_stop_loss_value* | float | Global stop loss threshold value |
| daily_stop_loss* | integer | Enable or disable daily stop loss mode (0-7) |
| daily_stop_loss_type* | integer | Daily stop loss calculation type (0=Close Only, 1= Close All and Disable Copy, 2= Disable Copy) |
| daily_stop_loss_value* | float | Daily stop loss threshold value |
| Protection modes | Value | Description |
|---|---|---|
| daily_stop_loss | 0 | OFF |
| 2 | Daily Net Loss Amount | |
| 3 | Daily Net Loss % | |
| 4 | Daily Drawdown Amount | |
| 5 | Daily Drawdown % | |
| daily_take_profit | 0 | OFF |
| 2 | Daily Net Profit Amount | |
| 3 | Daily Net Profit % | |
| global_stop_loss | 0 | OFF |
| 1 | Absolute Equity Stop | |
| 2 | Net Loss Amount | |
| 3 | Net Loss % | |
| 4 | Drawdown Amount | |
| 5 | Drawdown % | |
| 6 | Unrealized Loss Amount | |
| 7 | Unrealized Loss % | |
| global_take_profit | 0 | OFF |
| 1 | Absolute Equity Target | |
| 2 | Net Profit Amount | |
| 3 | Net Profit % | |
| 6 | Unrealized Profit Amount | |
| 7 | Unrealized Profit % |
PHP example
<?php
$url="https://www.trade-copier.com/webservice/v4/protection/setGlobalProtection.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);
//Filter can specify a mix of fields, they are all optional (except slave id)
$filter = ['slave_id' => 'ABC', 'stop_loss' => 1, 'stop_loss_type' => 0, 'take_profit' => 1, 'take_profit_value' => 10.05];
//$filter = ['slave_id' => 'ABC', 'stop_loss_type' => 2, 'take_profit' => 0];
//$filter = ['slave_id' => 'ABC', 'stop_loss' => 1, 'stop_loss_type' => 0, 'stop_loss_value' => 20 'take_profit' => 1, 'take_profit_type' => 0, 'take_profit_value' => 10.05];
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($filter));
// Execute request
$json = json_decode(curl_exec($ch));
// Close connection
curl_close($ch);
//Success message or error
if(array_key_exists('success', $json)) {
echo $json->code."-".$json->success;
} else {
//This is an error message that can be access like this:
//echo $json->code." ".$json->error;
echo json_encode($json);
}
?>