stable/docs/stoploss.md

85 lines
4.7 KiB
Markdown
Raw Normal View History

2019-05-20 18:06:13 +00:00
# Stop Loss
The `stoploss` configuration parameter is loss in percentage that should trigger a sale.
For example, value `-0.10` will cause immediate sell if the profit dips below -10% for a given trade. This parameter is optional.
Most of the strategy files already include the optimal `stoploss`
value. This parameter is optional. If you use it in the configuration file, it will take over the
`stoploss` value from the strategy file.
## Stop Loss support
2018-06-02 03:50:40 +00:00
2018-06-26 18:26:28 +00:00
At this stage the bot contains the following stoploss support modes:
2018-06-02 03:50:40 +00:00
2019-01-16 18:22:06 +00:00
1. static stop loss, defined in either the strategy or configuration.
2. trailing stop loss, defined in the configuration.
3. trailing stop loss, custom positive loss, defined in configuration.
2018-06-02 03:50:40 +00:00
!!! Note
2019-01-16 18:22:06 +00:00
All stoploss properties can be configured in either Strategy or configuration. Configuration values override strategy values.
2019-01-18 11:00:02 +00:00
Those stoploss modes can be *on exchange* or *off exchange*. If the stoploss is *on exchange* it means a stoploss limit order is placed on the exchange immediately after buy order happens successfuly. This will protect you against sudden crashes in market as the order will be in the queue immediately and if market goes down then the order has more chance of being fulfilled.
2019-01-16 18:22:06 +00:00
2019-01-18 11:00:53 +00:00
In case of stoploss on exchange there is another parameter called `stoploss_on_exchange_interval`. This configures the interval in seconds at which the bot will check the stoploss and update it if necessary. As an example in case of trailing stoploss if the order is on the exchange and the market is going up then the bot automatically cancels the previous stoploss order and put a new one with a stop value higher than previous one. It is clear that the bot cannot do it every 5 seconds otherwise it gets banned. So this parameter will tell the bot how often it should update the stoploss order. The default value is 60 (1 minute).
2019-01-16 18:22:06 +00:00
2019-01-16 18:23:55 +00:00
!!! Note
Stoploss on exchange is only supported for Binance as of now.
2018-06-02 03:50:40 +00:00
## Static Stop Loss
This is very simple, basically you define a stop loss of x in your strategy file or alternative in the configuration, which
will overwrite the strategy definition. This will basically try to sell your asset, the second the loss exceeds the defined loss.
2019-05-20 18:06:13 +00:00
## Trailing Stop Loss
2018-06-02 03:50:40 +00:00
The initial value for this stop loss, is defined in your strategy or configuration. Just as you would define your Stop Loss normally.
2018-06-26 18:26:28 +00:00
To enable this Feauture all you have to do is to define the configuration element:
2018-06-02 03:50:40 +00:00
2018-06-26 18:26:28 +00:00
``` json
2018-06-02 03:50:40 +00:00
"trailing_stop" : True
```
2018-06-26 18:26:28 +00:00
This will now activate an algorithm, which automatically moves your stop loss up every time the price of your asset increases.
2018-06-02 03:50:40 +00:00
For example, simplified math,
* you buy an asset at a price of 100$
* your stop loss is defined at 2%
* which means your stop loss, gets triggered once your asset dropped below 98$
2018-06-26 18:26:28 +00:00
* assuming your asset now increases to 102$
2018-06-02 03:50:40 +00:00
* your stop loss, will now be 2% of 102$ or 99.96$
* now your asset drops in value to 101$, your stop loss, will still be 99.96$
2018-06-26 18:26:28 +00:00
basically what this means is that your stop loss will be adjusted to be always be 2% of the highest observed price
2018-06-02 03:50:40 +00:00
### Custom positive loss
Due to demand, it is possible to have a default stop loss, when you are in the red with your buy, but once your profit surpasses a certain percentage,
the system will utilize a new stop loss, which can be a different value. For example your default stop loss is 5%, but once you have 1.1% profit,
it will be changed to be only a 1% stop loss, which trails the green candles until it goes below them.
2018-06-02 03:50:40 +00:00
Both values can be configured in the main configuration file and requires `"trailing_stop": true` to be set to true.
2018-06-02 03:50:40 +00:00
2018-06-26 18:26:28 +00:00
``` json
"trailing_stop_positive": 0.01,
"trailing_stop_positive_offset": 0.011,
2019-03-12 14:48:30 +00:00
"trailing_only_offset_is_reached": false
2018-06-02 03:50:40 +00:00
```
2018-06-26 18:26:28 +00:00
The 0.01 would translate to a 1% stop loss, once you hit 1.1% profit.
You should also make sure to have this value (`trailing_stop_positive_offset`) lower than your minimal ROI, otherwise minimal ROI will apply first and sell your trade.
2019-03-12 14:48:30 +00:00
2019-03-16 09:38:32 +00:00
If `"trailing_only_offset_is_reached": true` then the trailing stoploss is only activated once the offset is reached. Until then, the stoploss remains at the configured`stoploss`.
2019-05-20 18:06:35 +00:00
## Changing stoploss on open trades
A stoploss on an open trade can be changed by changing the value in the configuration or strategy and use the `/reload_conf` command (alternatively, completely stopping and restarting the bot also works).
The new stoploss value will be applied to open trades (and corresponding log-messages will be generated).
### Limitations
Stoploss values cannot be changed if `trailing_stop` is enabled and the stoploss has already been adjusted, or if [Edge](edge.md) is enabled (since Edge would recalculate stoploss based on the current market situation).