Update stoploss.md

Updated documentation to simplify examples
This commit is contained in:
Fredrik81 2020-08-16 03:02:10 +02:00 committed by GitHub
parent 89b9a8cb1f
commit b9e46a3c5a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 83 additions and 34 deletions

View File

@ -6,16 +6,10 @@ For example, value `-0.10` will cause immediate sell if the profit dips below -1
Most of the strategy files already include the optimal `stoploss` value.
!!! Info
All stoploss properties mentioned in this file can be set in the Strategy, or in the configuration. Configuration values will override the strategy values.
All stoploss properties mentioned in this file can be set in the Strategy, or in the configuration.
<ins>Configuration values will override the strategy values.</ins>
## Stop Loss Types
At this stage the bot contains the following stoploss support modes:
1. Static stop loss.
2. Trailing stop loss.
3. Trailing stop loss, custom positive loss.
4. Trailing stop loss only once the trade has reached a certain offset.
## Stop Loss On-Exchange/Freqtrade
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 successfully. 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.
@ -27,19 +21,58 @@ So this parameter will tell the bot how often it should update the stoploss orde
This same logic will reapply a stoploss order on the exchange should you cancel it accidentally.
!!! Note
Stoploss on exchange is only supported for Binance (stop-loss-limit), Kraken (stop-loss-market) and FTX (stop limit and stop-market) as of now.
Stoploss on exchange is only supported for Binance (stop-loss-limit), Kraken (stop-loss-market) and FTX (stop limit and stop-market) as of now.
Do not set too low stoploss value if using stop loss on exhange!
## Static Stop Loss
Stop loss on exchange is controlled with this value (default False):
``` python
'stoploss_on_exchange': False
```
Example from strategy file:
``` python
order_types = {
'buy': 'limit',
'sell': 'limit',
'stoploss': 'market',
'stoploss_on_exchange': True
}
```
## Stop Loss Types
At this stage the bot contains the following stoploss support modes:
1. Static stop loss.
2. Trailing stop loss.
3. Trailing stop loss, custom positive loss.
4. Trailing stop loss only once the trade has reached a certain offset.
### Static Stop Loss
This is very simple, you define a stop loss of x (as a ratio of price, i.e. x * 100% of price). This will try to sell the asset once the loss exceeds the defined loss.
## Trailing Stop Loss
Example of stop loss:
``` python
stoploss = -0.10
```
For example, simplified math:
* the bot buys an asset at a price of 100$
* the stop loss is defined at -10%
* the stop loss would get triggered once the asset dropps below 90$
### Trailing Stop Loss
The initial value for this is `stoploss`, just as you would define your static Stop loss.
To enable trailing stoploss:
``` python
trailing_stop = True
stoploss = -0.10
trailing_stop = True
```
This will now activate an algorithm, which automatically moves the stop loss up every time the price of your asset increases.
@ -47,35 +80,40 @@ This will now activate an algorithm, which automatically moves the stop loss up
For example, simplified math:
* the bot buys an asset at a price of 100$
* the stop loss is defined at 2%
* the stop loss would get triggered once the asset dropps below 98$
* the stop loss is defined at -10%
* the stop loss would get triggered once the asset dropps below 90$
* assuming the asset now increases to 102$
* the stop loss will now be 2% of 102$ or 99.96$
* now the asset drops in value to 101$, the stop loss will still be 99.96$ and would trigger at 99.96$.
* the stop loss will now be -10% of 102$ = 91,8$
* now the asset drops in value to 101$, the stop loss will still be 91,8$ and would trigger at 91,8$.
In summary: The stoploss will be adjusted to be always be 2% of the highest observed price.
### Custom positive stoploss
### Trailing stop loss, custom positive loss
It is also 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 have 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.
It is also possible to have a default stop loss, when you are in the red with your buy (buy - fee), but once you hit possitive result the system will utilize a new stop loss, which can have a different value.
For example your default stop loss is -10%, but once you have more than 0% profit (example 0.1%) a different trailing stoploss will be used.
Both values require `trailing_stop` to be set to true.
Both values require `trailing_stop` to be set to true and trailing_stop_positive with a value.
``` python
trailing_stop_positive = 0.01
trailing_stop_positive_offset = 0.011
stoploss = -0.10
trailing_stop = True
trailing_stop_positive = 0.02
```
The 0.01 would translate to a 1% stop loss, once you hit 1.1% profit.
For example, simplified math:
* the bot buys an asset at a price of 100$
* the stop loss is defined at -10%
* the stop loss would get triggered once the asset dropps below 90$
* assuming the asset now increases to 102$
* the stop loss will now be -2% of 102$ = 99,96$
* now the asset drops in value to 101$, the stop loss will still be 99,96$ and would trigger at 99,96$
The 0.02 would translate to a -2% stop loss.
Before this, `stoploss` is used for the trailing stoploss.
Read the [next section](#trailing-only-once-offset-is-reached) to keep stoploss at 5% of the entry point.
!!! Tip
Make sure to have this value (`trailing_stop_positive_offset`) lower than minimal ROI, otherwise minimal ROI will apply first and sell the trade.
### Trailing only once offset is reached
### Trailing stop loss only once the trade has reached a certain offset.
It is also possible to use a static stoploss until the offset is reached, and then trail the trade to take profits once the market turns.
@ -87,17 +125,28 @@ This option can be used with or without `trailing_stop_positive`, but uses `trai
trailing_only_offset_is_reached = True
```
Simplified example:
Configuration (offset is buyprice + 3%):
``` python
stoploss = 0.05
stoploss = -0.10
trailing_stop = True
trailing_stop_positive = 0.02
trailing_stop_positive_offset = 0.03
trailing_only_offset_is_reached = True
```
For example, simplified math:
* the bot buys an asset at a price of 100$
* the stop loss is defined at 5%
* the stop loss will remain at 95% until profit reaches +3%
* the stop loss is defined at -10%
* the stop loss would get triggered once the asset dropps below 90$
* stoploss will remain at 90$ unless asset increases to or above our configured offset
* assuming the asset now increases to 103$ (where we have the offset configured)
* the stop loss will now be -2% of 103$ = 100,94$
* now the asset drops in value to 101$, the stop loss will still be 100,94$ and would trigger at 100,94$
!!! Tip
Make sure to have this value (`trailing_stop_positive_offset`) lower than minimal ROI, otherwise minimal ROI will apply first and sell the trade.
## Changing stoploss on open trades