Trailing stop loss
About
Contains distance trailing stop loss configuration
Fields
| Name |
Type |
Required |
Description |
| distance |
DistanceTrailingStopLoss |
|
distance trailing stop loss configuration. If both distance and threshold TSL are set, then the resulting SL will be the one which is closest to the current price |
| threshold |
ThresholdTrailingStopLoss |
|
threshold trailing stop loss configuration. If both distance and threshold TSL are set, then the resulting SL will be the one which is closest to the current price |
DistanceTrailingStopLoss model fields
| Name |
Type |
Required |
Description |
| distance |
number |
Yes |
SL distance relative to current price, interpreted according to units field value |
| units |
string |
|
distance trailing stop loss units. RELATIVE_* means that the distance field value contains relative stop loss expressed either in price, points, pips, account currency or balance percentage. Default is RELATIVE_PRICE, enum: RELATIVE_PRICE, RELATIVE_POINTS, RELATIVE_PIPS, RELATIVE_CURRENCY, RELATIVE_BALANCE_PERCENTAGE |
ThresholdTrailingStopLoss model fields
| Name |
Type |
Required |
Description |
| thresholds |
Array<StopLossThreshold> |
Yes |
stop loss threshold |
| units |
string |
|
threshold stop loss units. ABSOLUTE_PRICE means the that the value of stop loss threshold fields contains a final threshold & stop loss value. RELATIVE_* means that the threshold fields value contains relative threshold & stop loss values, expressed either in price, points, pips, account currency or balance percentage. Default is ABSOLUTE_PRICE, enum: ABSOLUTE_PRICE, RELATIVE_PRICE, RELATIVE_POINTS, RELATIVE_PIPS, RELATIVE_CURRENCY, RELATIVE_BALANCE_PERCENTAGE |
| stopPriceBase |
string |
|
defined the base price to calculate SL relative to for *_MODIFY and pending order requests. Default is OPEN_PRICE, enum: CURRENT_PRICE, OPEN_PRICE |
StopLossThreshold model fields
| Name |
Type |
Required |
Description |
| threshold |
number |
Yes |
price threshold to activate next trailing SL at. When units is ABSOLUTE_PRICE, the value represents the final price. When RELATIVE* units are used, the value represents an offset from the position open price in the direction of the profitable price change (i.e. the threshold is added to the open price for buy positions and decremented from the open price for sell positions). You may specify a negative value for this field if it makes any sense from business logic point of view for you. It may be useful when the trailing stop loss is configured after position has opened and is unprofitable currently, so the threshold would be set in the direction of profitable price change from the current price while being set in unprofitable direction relatively to the open price |
| stopLoss |
number |
Yes |
trailing stop loss value, which shall be interpreted differently according to units and stopBasePrice field values. When units is ABSOLUTE_PRICE, the value represents the final price. When RELATIVE* units are used, the value represents an offset from the base price (as defined by stopPriceBase). For the CURRENT_PRICE stopPriceBase value, the stop loss value is interpreted as a distance in the direction of the unprofitable price change (i.e. the stopLoss is decremented from the current price for buy positions and added to the current price for sell positions). For the OPEN_PRICE stopPriceBase value, the stop loss value is interpreted as a distance in the direction of the profitable price change (i.e. the stopLoss is added to the open price for buy positions and decremented from the open price for sell positions). You may specify negative value for stopLoss field to achieve the effect of reversing a relative stop loss direction. On each trailing SL update, the system will apply the updated SL only if it is valid from the trading rules point of view. This means that the new SL value must be below market price for buy positions and above market price for sell positions. This also means that the new SL value must move in the profitable price direction compared to the previous SL value. If any of these conditions does not hold true, the trailing SL update will be skipped |
Example
{
"distance": {
"distance": 0.1,
"units": "RELATIVE_PRICE"
},
"threshold": {
"thresholds": [
{
"threshold": 1.3,
"stopLoss": 1.1
}
],
"units": "ABSOLUTE_PRICE",
"stopPriceBase": "CURRENT_PRICE"
}
}
Usages