From b9e46a3c5a0d2f2ad4f8b18af9d31385fa73e325 Mon Sep 17 00:00:00 2001 From: Fredrik81 Date: Sun, 16 Aug 2020 03:02:10 +0200 Subject: [PATCH 01/20] Update stoploss.md Updated documentation to simplify examples --- docs/stoploss.md | 117 +++++++++++++++++++++++++++++++++-------------- 1 file changed, 83 insertions(+), 34 deletions(-) diff --git a/docs/stoploss.md b/docs/stoploss.md index bf7270dff..2945c18db 100644 --- a/docs/stoploss.md +++ b/docs/stoploss.md @@ -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. + Configuration values will override the strategy values. -## 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 From bae8e5ed1a535435a580a2f39776929adc0046cd Mon Sep 17 00:00:00 2001 From: Fredrik81 Date: Sun, 16 Aug 2020 13:03:56 +0200 Subject: [PATCH 02/20] Update docs/stoploss.md Co-authored-by: Matthias --- docs/stoploss.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/stoploss.md b/docs/stoploss.md index 2945c18db..32c304e60 100644 --- a/docs/stoploss.md +++ b/docs/stoploss.md @@ -63,7 +63,7 @@ Example of stop loss: 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$ +* the stop loss would get triggered once the asset drops below 90$ ### Trailing Stop Loss From c60192e4bdd5440c9f1c5ff2d039c269935a71f4 Mon Sep 17 00:00:00 2001 From: Fredrik81 Date: Sun, 16 Aug 2020 13:05:07 +0200 Subject: [PATCH 03/20] Update docs/stoploss.md Co-authored-by: Matthias --- docs/stoploss.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/stoploss.md b/docs/stoploss.md index 32c304e60..8bb68eb1d 100644 --- a/docs/stoploss.md +++ b/docs/stoploss.md @@ -81,7 +81,7 @@ 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$ +* the stop loss would get triggered once the asset drops below 90$ * assuming the asset now increases to 102$ * 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$. From 1ce392f65208b9a1426d414eae4712ac72ed6ce1 Mon Sep 17 00:00:00 2001 From: Fredrik81 Date: Sun, 16 Aug 2020 13:05:38 +0200 Subject: [PATCH 04/20] Update docs/stoploss.md Co-authored-by: Matthias --- docs/stoploss.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/docs/stoploss.md b/docs/stoploss.md index 8bb68eb1d..dbe839cab 100644 --- a/docs/stoploss.md +++ b/docs/stoploss.md @@ -37,7 +37,9 @@ order_types = { 'buy': 'limit', 'sell': 'limit', 'stoploss': 'market', - 'stoploss_on_exchange': True + 'stoploss_on_exchange': True, + 'stoploss_on_exchange_interval': 60, + 'stoploss_on_exchange_limit_ratio': 0.99 } ``` From 4ade3daa1ef1fd25e523314acd6b209a494e2c8f Mon Sep 17 00:00:00 2001 From: Fredrik81 Date: Sun, 16 Aug 2020 13:09:19 +0200 Subject: [PATCH 05/20] Update docs/stoploss.md Co-authored-by: Matthias --- docs/stoploss.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/stoploss.md b/docs/stoploss.md index dbe839cab..57d6c160e 100644 --- a/docs/stoploss.md +++ b/docs/stoploss.md @@ -85,8 +85,8 @@ For example, simplified math: * the stop loss is defined at -10% * the stop loss would get triggered once the asset drops below 90$ * assuming the asset now increases to 102$ -* 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$. +* 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. From 902d40a32a7a9ed9992a4743e9a16cc7226cf28d Mon Sep 17 00:00:00 2001 From: Fredrik81 Date: Sun, 16 Aug 2020 13:13:27 +0200 Subject: [PATCH 06/20] Update docs/stoploss.md Co-authored-by: Matthias --- docs/stoploss.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/stoploss.md b/docs/stoploss.md index 57d6c160e..7942b4c68 100644 --- a/docs/stoploss.md +++ b/docs/stoploss.md @@ -95,7 +95,7 @@ In summary: The stoploss will be adjusted to be always be 2% of the highest obse 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 and trailing_stop_positive with a value. +Both values require `trailing_stop` to be set to true and `trailing_stop_positive` with a value. ``` python stoploss = -0.10 From e30a38932f47406dde2cef8ec956358ff95bbf48 Mon Sep 17 00:00:00 2001 From: Fredrik81 Date: Sun, 16 Aug 2020 13:13:40 +0200 Subject: [PATCH 07/20] Update docs/stoploss.md Co-authored-by: Matthias --- docs/stoploss.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/stoploss.md b/docs/stoploss.md index 7942b4c68..e6cc59c83 100644 --- a/docs/stoploss.md +++ b/docs/stoploss.md @@ -107,7 +107,7 @@ 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$ +* the stop loss would get triggered once the asset drops 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$ From 4a0c988b678509cfe3fc61d87a015197b3d063a2 Mon Sep 17 00:00:00 2001 From: Fredrik81 Date: Sun, 16 Aug 2020 13:13:54 +0200 Subject: [PATCH 08/20] Update docs/stoploss.md Co-authored-by: Matthias --- docs/stoploss.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/stoploss.md b/docs/stoploss.md index e6cc59c83..142dfd2c9 100644 --- a/docs/stoploss.md +++ b/docs/stoploss.md @@ -109,8 +109,8 @@ For example, simplified math: * the stop loss is defined at -10% * the stop loss would get triggered once the asset drops 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 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. From 67e9721274aa2bd1e23654b0befadce93ade8ce0 Mon Sep 17 00:00:00 2001 From: Fredrik81 Date: Sun, 16 Aug 2020 13:14:50 +0200 Subject: [PATCH 09/20] Update docs/stoploss.md Co-authored-by: Matthias --- docs/stoploss.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/stoploss.md b/docs/stoploss.md index 142dfd2c9..b866a3efa 100644 --- a/docs/stoploss.md +++ b/docs/stoploss.md @@ -115,7 +115,7 @@ For example, simplified math: The 0.02 would translate to a -2% stop loss. Before this, `stoploss` is used for the trailing stoploss. -### Trailing stop loss only once the trade has reached a certain offset. +### 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. From 8b348fc247416b04149d62a378c43bb6aa4dea89 Mon Sep 17 00:00:00 2001 From: Fredrik81 Date: Sun, 16 Aug 2020 13:16:35 +0200 Subject: [PATCH 10/20] Update docs/stoploss.md Co-authored-by: Matthias --- docs/stoploss.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/stoploss.md b/docs/stoploss.md index b866a3efa..30d866fff 100644 --- a/docs/stoploss.md +++ b/docs/stoploss.md @@ -92,7 +92,7 @@ In summary: The stoploss will be adjusted to be always be 2% of the highest obse ### 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 (buy - fee), but once you hit possitive result the system will utilize a new stop loss, which can have a different value. +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 positive 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 and `trailing_stop_positive` with a value. From 5091767276073528930d58b1f9d96b4d31da8133 Mon Sep 17 00:00:00 2001 From: Fredrik81 Date: Sun, 16 Aug 2020 13:17:01 +0200 Subject: [PATCH 11/20] Update docs/stoploss.md Co-authored-by: Matthias --- docs/stoploss.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/stoploss.md b/docs/stoploss.md index 30d866fff..ab3297ae9 100644 --- a/docs/stoploss.md +++ b/docs/stoploss.md @@ -141,7 +141,7 @@ 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$ +* the stop loss would get triggered once the asset drops 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$ From 81a75c97cf6a17e7ff2683d9003696059993ba97 Mon Sep 17 00:00:00 2001 From: Fredrik81 Date: Sun, 16 Aug 2020 13:17:11 +0200 Subject: [PATCH 12/20] Update docs/stoploss.md Co-authored-by: Matthias --- docs/stoploss.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/stoploss.md b/docs/stoploss.md index ab3297ae9..2cee88748 100644 --- a/docs/stoploss.md +++ b/docs/stoploss.md @@ -144,8 +144,8 @@ For example, simplified math: * the stop loss would get triggered once the asset drops 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$ +* 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. From ddba999fe2a25befa5ad6705956a6c9bc1776eb8 Mon Sep 17 00:00:00 2001 From: Fredrik81 Date: Sun, 16 Aug 2020 13:44:32 +0200 Subject: [PATCH 13/20] Update stoploss.md --- docs/stoploss.md | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/docs/stoploss.md b/docs/stoploss.md index 2cee88748..283826708 100644 --- a/docs/stoploss.md +++ b/docs/stoploss.md @@ -16,13 +16,14 @@ Those stoploss modes can be *on exchange* or *off exchange*. If the stoploss is 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. For example, assuming the stoploss is on exchange, and trailing stoploss is enabled, and the market is going up, then the bot automatically cancels the previous stoploss order and puts a new one with a stop value higher than the previous stoploss order. -The bot cannot do this every 5 seconds (at each iteration), otherwise it would get banned by the exchange. +The bot cannot do these every 5 seconds (at each iteration), otherwise it would get banned by the exchange. So this parameter will tell the bot how often it should update the stoploss order. The default value is 60 (1 minute). 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. - Do not set too low stoploss value if using stop loss on exhange! + Do not set too low stoploss value if using stop loss on exhange! +* If set to low/tight then you have greater risk of missing fill on the order and stoploss will not work Stop loss on exchange is controlled with this value (default False): @@ -88,12 +89,15 @@ For example, simplified math: * 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. +In summary: The stoploss will be adjusted to be always be -10% of the highest observed price. ### 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 (buy - fee), but once you hit positive 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. +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. + +!!! Note + If you want the stoploss to only be changed when you break even of making a profit (what most users want) please refere to next section with [offset enabled](#Trailing-stop-loss-only-once-the-trade-has-reached-a-certain-offset). Both values require `trailing_stop` to be set to true and `trailing_stop_positive` with a value. @@ -109,7 +113,7 @@ For example, simplified math: * the stop loss is defined at -10% * the stop loss would get triggered once the asset drops below 90$ * assuming the asset now increases to 102$ -* the stop loss will now be -2% of 102$ = 99.96$ +* the stop loss will now be -2% of 102$ = 99.96$ (99.96$ stop loss will be locked in and will follow asset price increasements with -2%) * 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. From f8efb87a676d872e950a496e52ef0de88d32216c Mon Sep 17 00:00:00 2001 From: Fredrik81 Date: Sun, 16 Aug 2020 14:57:53 +0200 Subject: [PATCH 14/20] Update docs/stoploss.md Co-authored-by: Matthias --- docs/stoploss.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/stoploss.md b/docs/stoploss.md index 283826708..5a8a553e7 100644 --- a/docs/stoploss.md +++ b/docs/stoploss.md @@ -87,7 +87,7 @@ For example, simplified math: * the stop loss would get triggered once the asset drops below 90$ * assuming the asset now increases to 102$ * 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$. +* 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 -10% of the highest observed price. From bd308889fcb49ba4decb7dc969d6b3886e3e49fc Mon Sep 17 00:00:00 2001 From: Fredrik81 Date: Sun, 16 Aug 2020 14:58:06 +0200 Subject: [PATCH 15/20] Update docs/stoploss.md Co-authored-by: Matthias --- docs/stoploss.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/stoploss.md b/docs/stoploss.md index 5a8a553e7..d0b7f654d 100644 --- a/docs/stoploss.md +++ b/docs/stoploss.md @@ -97,7 +97,7 @@ It is also possible to have a default stop loss, when you are in the red with yo 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. !!! Note - If you want the stoploss to only be changed when you break even of making a profit (what most users want) please refere to next section with [offset enabled](#Trailing-stop-loss-only-once-the-trade-has-reached-a-certain-offset). + If you want the stoploss to only be changed when you break even of making a profit (what most users want) please refer to next section with [offset enabled](#Trailing-stop-loss-only-once-the-trade-has-reached-a-certain-offset). Both values require `trailing_stop` to be set to true and `trailing_stop_positive` with a value. From 4619a50097074ff5686ecbff47594092fb169b5a Mon Sep 17 00:00:00 2001 From: Fredrik81 Date: Mon, 17 Aug 2020 02:07:25 +0200 Subject: [PATCH 16/20] Update configuration.md --- docs/configuration.md | 21 +++++---------------- 1 file changed, 5 insertions(+), 16 deletions(-) diff --git a/docs/configuration.md b/docs/configuration.md index a200d6411..ad18ac713 100644 --- a/docs/configuration.md +++ b/docs/configuration.md @@ -55,9 +55,9 @@ Mandatory parameters are marked as **Required**, which means that they are requi | `process_only_new_candles` | Enable processing of indicators only when new candles arrive. If false each loop populates the indicators, this will mean the same candle is processed many times creating system load but can be useful of your strategy depends on tick data not only candle. [Strategy Override](#parameters-in-the-strategy).
*Defaults to `false`.*
**Datatype:** Boolean | `minimal_roi` | **Required.** Set the threshold as ratio the bot will use to sell a trade. [More information below](#understand-minimal_roi). [Strategy Override](#parameters-in-the-strategy).
**Datatype:** Dict | `stoploss` | **Required.** Value as ratio of the stoploss used by the bot. More details in the [stoploss documentation](stoploss.md). [Strategy Override](#parameters-in-the-strategy).
**Datatype:** Float (as ratio) -| `trailing_stop` | Enables trailing stoploss (based on `stoploss` in either configuration or strategy file). More details in the [stoploss documentation](stoploss.md). [Strategy Override](#parameters-in-the-strategy).
**Datatype:** Boolean -| `trailing_stop_positive` | Changes stoploss once profit has been reached. More details in the [stoploss documentation](stoploss.md). [Strategy Override](#parameters-in-the-strategy).
**Datatype:** Float -| `trailing_stop_positive_offset` | Offset on when to apply `trailing_stop_positive`. Percentage value which should be positive. More details in the [stoploss documentation](stoploss.md). [Strategy Override](#parameters-in-the-strategy).
*Defaults to `0.0` (no offset).*
**Datatype:** Float +| `trailing_stop` | Enables trailing stoploss (based on `stoploss` in either configuration or strategy file). More details in the [stoploss documentation](stoploss.md#trailing-stop-loss). [Strategy Override](#parameters-in-the-strategy).
**Datatype:** Boolean +| `trailing_stop_positive` | Changes stoploss once profit has been reached. More details in the [stoploss documentation](stoploss.md#trailing-stop-loss-custom-positive-loss). [Strategy Override](#parameters-in-the-strategy).
**Datatype:** Float +| `trailing_stop_positive_offset` | Offset on when to apply `trailing_stop_positive`. Percentage value which should be positive. More details in the [stoploss documentation](stoploss.md#trailing-stop-loss-only-once-the-trade-has-reached-a-certain-offset). [Strategy Override](#parameters-in-the-strategy).
*Defaults to `0.0` (no offset).*
**Datatype:** Float | `trailing_only_offset_is_reached` | Only apply trailing stoploss when the offset is reached. [stoploss documentation](stoploss.md). [Strategy Override](#parameters-in-the-strategy).
*Defaults to `false`.*
**Datatype:** Boolean | `unfilledtimeout.buy` | **Required.** How long (in minutes) the bot will wait for an unfilled buy order to complete, after which the order will be cancelled. [Strategy Override](#parameters-in-the-strategy).
**Datatype:** Integer | `unfilledtimeout.sell` | **Required.** How long (in minutes) the bot will wait for an unfilled sell order to complete, after which the order will be cancelled. [Strategy Override](#parameters-in-the-strategy).
**Datatype:** Integer @@ -278,24 +278,13 @@ This allows to buy using limit orders, sell using limit-orders, and create stoplosses using market orders. It also allows to set the stoploss "on exchange" which means stoploss order would be placed immediately once the buy order is fulfilled. -If `stoploss_on_exchange` and `trailing_stop` are both set, then the bot will use `stoploss_on_exchange_interval` to check and update the stoploss on exchange periodically. -`order_types` can be set in the configuration file or in the strategy. + `order_types` set in the configuration file overwrites values set in the strategy as a whole, so you need to configure the whole `order_types` dictionary in one place. If this is configured, the following 4 values (`buy`, `sell`, `stoploss` and `stoploss_on_exchange`) need to be present, otherwise the bot will fail to start. -`emergencysell` is an optional value, which defaults to `market` and is used when creating stoploss on exchange orders fails. -The below is the default which is used if this is not configured in either strategy or configuration file. - -Not all Exchanges support `stoploss_on_exchange`. If an exchange supports both limit and market stoploss orders, then the value of `stoploss` will be used to determine the stoploss type. - -If `stoploss_on_exchange` uses limit orders, the exchange needs 2 prices, the stoploss_price and the Limit price. -`stoploss` defines the stop-price - and limit should be slightly below this. - -This defaults to 0.99 / 1% (configurable via `stoploss_on_exchange_limit_ratio`). -Calculation example: we bought the asset at 100$. -Stop-price is 95$, then limit would be `95 * 0.99 = 94.05$` - so the stoploss will happen between 95$ and 94.05$. +For information on (`emergencysell`,`stoploss_on_exchange`,`stoploss_on_exchange_interval`,`stoploss_on_exchange_limit_ratio`) please see stop loss documentation [stop loss on exchange](stoploss.md) Syntax for Strategy: From 2a6faaae64f6e5e3a5d85a7cf60d4574031e7189 Mon Sep 17 00:00:00 2001 From: Fredrik81 Date: Mon, 17 Aug 2020 02:07:32 +0200 Subject: [PATCH 17/20] Update stoploss.md --- docs/stoploss.md | 37 ++++++++++++++++++++++++++++++------- 1 file changed, 30 insertions(+), 7 deletions(-) diff --git a/docs/stoploss.md b/docs/stoploss.md index d0b7f654d..ffa125fa5 100644 --- a/docs/stoploss.md +++ b/docs/stoploss.md @@ -11,25 +11,47 @@ Most of the strategy files already include the optimal `stoploss` value. ## 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. +Those stoploss modes can be *on exchange* or *off exchange*. -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. +These modes can be configured with these values: + +``` python + 'emergencysell': 'market', + 'stoploss_on_exchange': False + 'stoploss_on_exchange_interval': 60, + 'stoploss_on_exchange_limit_ratio': 0.99 +``` + +### stoploss_on_exchange +Enable or Disable stop loss on 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. + +If `stoploss_on_exchange` uses limit orders, the exchange needs 2 prices, the stoploss_price and the Limit price. +`stoploss` defines the stop-price - and limit should be slightly below this. +If an exchange supports both limit and market stoploss orders, then the value of `stoploss` will be used to determine the stoploss type. For example, assuming the stoploss is on exchange, and trailing stoploss is enabled, and the market is going up, then the bot automatically cancels the previous stoploss order and puts a new one with a stop value higher than the previous stoploss order. + +### stoploss_on_exchange_interval +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. The bot cannot do these every 5 seconds (at each iteration), otherwise it would get banned by the exchange. So this parameter will tell the bot how often it should update the stoploss order. The default value is 60 (1 minute). This same logic will reapply a stoploss order on the exchange should you cancel it accidentally. +### emergencysell and stoploss_on_exchange_limit_ratio +`emergencysell` is an optional value, which defaults to `market` and is used when creating stop loss on exchange orders fails. +The below is the default which is used if this is not configured in either strategy or configuration file. + +This defaults to 0.99 / 1% (configurable via `stoploss_on_exchange_limit_ratio`). +Calculation example: we bought the asset at 100$. +Stop-price is 95$, then limit would be `95 * 0.99 = 94.05$` - so the stoploss will happen between 95$ and 94.05$. + + !!! 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. Do not set too low stoploss value if using stop loss on exhange! * If set to low/tight then you have greater risk of missing fill on the order and stoploss will not work -Stop loss on exchange is controlled with this value (default False): - -``` python - 'stoploss_on_exchange': False -``` Example from strategy file: @@ -37,6 +59,7 @@ Example from strategy file: order_types = { 'buy': 'limit', 'sell': 'limit', + 'emergencysell': 'market', 'stoploss': 'market', 'stoploss_on_exchange': True, 'stoploss_on_exchange_interval': 60, From d6ea442588a92493acaf9c9720e2f910028cc957 Mon Sep 17 00:00:00 2001 From: Fredrik81 Date: Mon, 17 Aug 2020 02:10:56 +0200 Subject: [PATCH 18/20] Update stoploss.md --- docs/stoploss.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/stoploss.md b/docs/stoploss.md index ffa125fa5..bbb0be566 100644 --- a/docs/stoploss.md +++ b/docs/stoploss.md @@ -49,7 +49,7 @@ Stop-price is 95$, then limit would be `95 * 0.99 = 94.05$` - so the stoploss wi !!! 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. - Do not set too low stoploss value if using stop loss on exhange! + Do not set too low stoploss value if using stop loss on exchange! * If set to low/tight then you have greater risk of missing fill on the order and stoploss will not work From 55c6e56762dc3d2523415641d1d25d903919de0c Mon Sep 17 00:00:00 2001 From: Fredrik81 Date: Wed, 19 Aug 2020 23:07:03 +0200 Subject: [PATCH 19/20] Update stoploss.md --- docs/stoploss.md | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/docs/stoploss.md b/docs/stoploss.md index bbb0be566..2595a3f55 100644 --- a/docs/stoploss.md +++ b/docs/stoploss.md @@ -22,7 +22,7 @@ These modes can be configured with these values: 'stoploss_on_exchange_limit_ratio': 0.99 ``` -### stoploss_on_exchange +### stoploss_on_exchange and stoploss_on_exchange_limit_ratio Enable or Disable stop loss on 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. @@ -30,6 +30,10 @@ If `stoploss_on_exchange` uses limit orders, the exchange needs 2 prices, the st `stoploss` defines the stop-price - and limit should be slightly below this. If an exchange supports both limit and market stoploss orders, then the value of `stoploss` will be used to determine the stoploss type. +If `stoploss_on_exchange` fails to fill we can use `stoploss_on_exchange_limit_ratio` that defaults to 0.99 / 1% to perform an [emergency sell](#emergencysell). +Calculation example: we bought the asset at 100$. +Stop-price is 95$, then limit would be `95 * 0.99 = 94.05$` - so the stoploss(emergency sell) will happen between 95$ and 94.05$. + For example, assuming the stoploss is on exchange, and trailing stoploss is enabled, and the market is going up, then the bot automatically cancels the previous stoploss order and puts a new one with a stop value higher than the previous stoploss order. ### stoploss_on_exchange_interval @@ -38,15 +42,10 @@ The bot cannot do these every 5 seconds (at each iteration), otherwise it would So this parameter will tell the bot how often it should update the stoploss order. The default value is 60 (1 minute). This same logic will reapply a stoploss order on the exchange should you cancel it accidentally. -### emergencysell and stoploss_on_exchange_limit_ratio +### emergencysell `emergencysell` is an optional value, which defaults to `market` and is used when creating stop loss on exchange orders fails. The below is the default which is used if this is not configured in either strategy or configuration file. -This defaults to 0.99 / 1% (configurable via `stoploss_on_exchange_limit_ratio`). -Calculation example: we bought the asset at 100$. -Stop-price is 95$, then limit would be `95 * 0.99 = 94.05$` - so the stoploss will happen between 95$ and 94.05$. - - !!! 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. Do not set too low stoploss value if using stop loss on exchange! From 0e368b16aba83de72328b52f1e867d6ee5c9bcd1 Mon Sep 17 00:00:00 2001 From: Fredrik81 Date: Fri, 21 Aug 2020 18:25:45 +0200 Subject: [PATCH 20/20] Update stoploss.md --- docs/stoploss.md | 34 ++++++++++++++++------------------ 1 file changed, 16 insertions(+), 18 deletions(-) diff --git a/docs/stoploss.md b/docs/stoploss.md index 2595a3f55..2518df846 100644 --- a/docs/stoploss.md +++ b/docs/stoploss.md @@ -6,8 +6,8 @@ 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. +* Configuration values will override the strategy values. ## Stop Loss On-Exchange/Freqtrade @@ -22,35 +22,33 @@ These modes can be configured with these values: 'stoploss_on_exchange_limit_ratio': 0.99 ``` +!!! 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. +* Do not set too low stoploss value if using stop loss on exchange! +* If set to low/tight then you have greater risk of missing fill on the order and stoploss will not work + ### stoploss_on_exchange and stoploss_on_exchange_limit_ratio Enable or Disable stop loss on 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. -If `stoploss_on_exchange` uses limit orders, the exchange needs 2 prices, the stoploss_price and the Limit price. -`stoploss` defines the stop-price - and limit should be slightly below this. -If an exchange supports both limit and market stoploss orders, then the value of `stoploss` will be used to determine the stoploss type. +If `stoploss_on_exchange` uses limit orders, the exchange needs 2 prices, the stoploss_price and the Limit price. +`stoploss` defines the stop-price where the limit order is placed - and limit should be slightly below this. +If an exchange supports both limit and market stoploss orders, then the value of `stoploss` will be used to determine the stoploss type. -If `stoploss_on_exchange` fails to fill we can use `stoploss_on_exchange_limit_ratio` that defaults to 0.99 / 1% to perform an [emergency sell](#emergencysell). -Calculation example: we bought the asset at 100$. -Stop-price is 95$, then limit would be `95 * 0.99 = 94.05$` - so the stoploss(emergency sell) will happen between 95$ and 94.05$. +Calculation example: we bought the asset at 100$. +Stop-price is 95$, then limit would be `95 * 0.99 = 94.05$` - so the limit order fill can happen between 95$ and 94.05$. For example, assuming the stoploss is on exchange, and trailing stoploss is enabled, and the market is going up, then the bot automatically cancels the previous stoploss order and puts a new one with a stop value higher than the previous stoploss order. ### stoploss_on_exchange_interval -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. +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. The bot cannot do these every 5 seconds (at each iteration), otherwise it would get banned by the exchange. So this parameter will tell the bot how often it should update the stoploss order. The default value is 60 (1 minute). This same logic will reapply a stoploss order on the exchange should you cancel it accidentally. ### emergencysell `emergencysell` is an optional value, which defaults to `market` and is used when creating stop loss on exchange orders fails. -The below is the default which is used if this is not configured in either strategy or configuration file. - -!!! 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. - Do not set too low stoploss value if using stop loss on exchange! -* If set to low/tight then you have greater risk of missing fill on the order and stoploss will not work - +The below is the default which is used if not changed in strategy or configuration file. Example from strategy file: @@ -119,7 +117,7 @@ It is also possible to have a default stop loss, when you are in the red with yo 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. !!! Note - If you want the stoploss to only be changed when you break even of making a profit (what most users want) please refer to next section with [offset enabled](#Trailing-stop-loss-only-once-the-trade-has-reached-a-certain-offset). +* If you want the stoploss to only be changed when you break even of making a profit (what most users want) please refer to next section with [offset enabled](#Trailing-stop-loss-only-once-the-trade-has-reached-a-certain-offset). Both values require `trailing_stop` to be set to true and `trailing_stop_positive` with a value. @@ -174,7 +172,7 @@ For example, simplified math: * 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. +* 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