From f432e65a147ad543f8dbbcef7fbc7972b004e278 Mon Sep 17 00:00:00 2001 From: Matthias Date: Sun, 25 May 2025 09:42:37 +0200 Subject: [PATCH 1/6] docs: add "exit logic comparisons" table --- docs/strategy-callbacks.md | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/docs/strategy-callbacks.md b/docs/strategy-callbacks.md index 38feada4b..12b43f92d 100644 --- a/docs/strategy-callbacks.md +++ b/docs/strategy-callbacks.md @@ -27,6 +27,24 @@ Currently available callbacks: --8<-- "includes/strategy-imports.md" +## Exit logic comparisons + +Freqtrade allows your strategy to implement different exit logics. +This section aims to compare each different section, helping you to choose the one that best fits your needs. + +* **`populate_exit_trend()`** - Vectorized exit logic based on the dataframe + * ✅ **Use** to define exit conditions based on indicators or other data that can be calculated in a vectorized manner. + * 🚫 **Don't use** to customize exit conditions for each individual trade, or if trade data is necessary to make an exit decision. +* **`custom_exit()`** - Custom exit signal, called for every open trade every iteration until a trade is closed. + * ✅ **Use** to customize exit conditions for each individual trade, or if trade data is necessary to make an exit decision. +* **`custom_stoploss()`** - Custom stoploss, called for every open trade every iteration until a trade is closed. The value returned here is also used for [stoploss on exchange](stoploss.md#stop-loss-on-exchangefreqtrade). + * ✅ **Use** to customize the stoploss logic to set a dynamic stoploss based on trade data or other conditions. + * 🚫 **Don't use** to exit a trade immediately based on a specific condition. Use `custom_exit()` for that purpose. +* **`custom_roi()`** - Custom ROI, called for every open trade every iteration until a trade is closed. + * ✅ **Use** to customize the minimum ROI threshold to exit a trade dynamically based on profit or other conditions. + * 🚫 **Don't use** to exit a trade immediately based on a specific condition. Use `custom_exit()` for that purpose. + * 🚫 **Don't use** for static roi. Use `minimal_roi` for that purpose instead. + ## Bot start A simple callback which is called once when the strategy is loaded. From 929538dd5fa6400ca3ac2a5665b3cdf1de976771 Mon Sep 17 00:00:00 2001 From: Matthias Date: Sun, 25 May 2025 09:44:52 +0200 Subject: [PATCH 2/6] docs: refactor exit logic comparisons to includes file this might allow us to reuse this in other parts of the docs. --- docs/includes/strategy-exit-comparisons.md | 17 +++++++++++++++++ docs/strategy-callbacks.md | 17 +---------------- 2 files changed, 18 insertions(+), 16 deletions(-) create mode 100644 docs/includes/strategy-exit-comparisons.md diff --git a/docs/includes/strategy-exit-comparisons.md b/docs/includes/strategy-exit-comparisons.md new file mode 100644 index 000000000..6ee11e5d1 --- /dev/null +++ b/docs/includes/strategy-exit-comparisons.md @@ -0,0 +1,17 @@ +## Exit logic comparisons + +Freqtrade allows your strategy to implement different exit logics. +This section aims to compare each different section, helping you to choose the one that best fits your needs. + +* **`populate_exit_trend()`** - Vectorized exit logic based on the dataframe + * ✅ **Use** to define exit conditions based on indicators or other data that can be calculated in a vectorized manner. + * 🚫 **Don't use** to customize exit conditions for each individual trade, or if trade data is necessary to make an exit decision. +* **`custom_exit()`** - Custom exit signal, called for every open trade every iteration until a trade is closed. + * ✅ **Use** to customize exit conditions for each individual trade, or if trade data is necessary to make an exit decision. +* **`custom_stoploss()`** - Custom stoploss, called for every open trade every iteration until a trade is closed. The value returned here is also used for [stoploss on exchange](stoploss.md#stop-loss-on-exchangefreqtrade). + * ✅ **Use** to customize the stoploss logic to set a dynamic stoploss based on trade data or other conditions. + * 🚫 **Don't use** to exit a trade immediately based on a specific condition. Use `custom_exit()` for that purpose. +* **`custom_roi()`** - Custom ROI, called for every open trade every iteration until a trade is closed. + * ✅ **Use** to customize the minimum ROI threshold to exit a trade dynamically based on profit or other conditions. + * 🚫 **Don't use** to exit a trade immediately based on a specific condition. Use `custom_exit()` for that purpose. + * 🚫 **Don't use** for static roi. Use `minimal_roi` for that purpose instead. diff --git a/docs/strategy-callbacks.md b/docs/strategy-callbacks.md index 12b43f92d..ecc2cbb9b 100644 --- a/docs/strategy-callbacks.md +++ b/docs/strategy-callbacks.md @@ -27,23 +27,8 @@ Currently available callbacks: --8<-- "includes/strategy-imports.md" -## Exit logic comparisons +--8<-- "includes/strategy-exit-comparisons.md" -Freqtrade allows your strategy to implement different exit logics. -This section aims to compare each different section, helping you to choose the one that best fits your needs. - -* **`populate_exit_trend()`** - Vectorized exit logic based on the dataframe - * ✅ **Use** to define exit conditions based on indicators or other data that can be calculated in a vectorized manner. - * 🚫 **Don't use** to customize exit conditions for each individual trade, or if trade data is necessary to make an exit decision. -* **`custom_exit()`** - Custom exit signal, called for every open trade every iteration until a trade is closed. - * ✅ **Use** to customize exit conditions for each individual trade, or if trade data is necessary to make an exit decision. -* **`custom_stoploss()`** - Custom stoploss, called for every open trade every iteration until a trade is closed. The value returned here is also used for [stoploss on exchange](stoploss.md#stop-loss-on-exchangefreqtrade). - * ✅ **Use** to customize the stoploss logic to set a dynamic stoploss based on trade data or other conditions. - * 🚫 **Don't use** to exit a trade immediately based on a specific condition. Use `custom_exit()` for that purpose. -* **`custom_roi()`** - Custom ROI, called for every open trade every iteration until a trade is closed. - * ✅ **Use** to customize the minimum ROI threshold to exit a trade dynamically based on profit or other conditions. - * 🚫 **Don't use** to exit a trade immediately based on a specific condition. Use `custom_exit()` for that purpose. - * 🚫 **Don't use** for static roi. Use `minimal_roi` for that purpose instead. ## Bot start From 1afddf9db4467b3f731881a664253b01a3b1df1a Mon Sep 17 00:00:00 2001 From: Matthias Date: Sun, 25 May 2025 10:01:39 +0200 Subject: [PATCH 3/6] docs: no dots on exit comparison --- docs/includes/strategy-exit-comparisons.md | 24 +++++++++++----------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/docs/includes/strategy-exit-comparisons.md b/docs/includes/strategy-exit-comparisons.md index 6ee11e5d1..9abbda7fa 100644 --- a/docs/includes/strategy-exit-comparisons.md +++ b/docs/includes/strategy-exit-comparisons.md @@ -3,15 +3,15 @@ Freqtrade allows your strategy to implement different exit logics. This section aims to compare each different section, helping you to choose the one that best fits your needs. -* **`populate_exit_trend()`** - Vectorized exit logic based on the dataframe - * ✅ **Use** to define exit conditions based on indicators or other data that can be calculated in a vectorized manner. - * 🚫 **Don't use** to customize exit conditions for each individual trade, or if trade data is necessary to make an exit decision. -* **`custom_exit()`** - Custom exit signal, called for every open trade every iteration until a trade is closed. - * ✅ **Use** to customize exit conditions for each individual trade, or if trade data is necessary to make an exit decision. -* **`custom_stoploss()`** - Custom stoploss, called for every open trade every iteration until a trade is closed. The value returned here is also used for [stoploss on exchange](stoploss.md#stop-loss-on-exchangefreqtrade). - * ✅ **Use** to customize the stoploss logic to set a dynamic stoploss based on trade data or other conditions. - * 🚫 **Don't use** to exit a trade immediately based on a specific condition. Use `custom_exit()` for that purpose. -* **`custom_roi()`** - Custom ROI, called for every open trade every iteration until a trade is closed. - * ✅ **Use** to customize the minimum ROI threshold to exit a trade dynamically based on profit or other conditions. - * 🚫 **Don't use** to exit a trade immediately based on a specific condition. Use `custom_exit()` for that purpose. - * 🚫 **Don't use** for static roi. Use `minimal_roi` for that purpose instead. +* **`populate_exit_trend()`** - Vectorized exit logic based on the dataframe + ✅ **Use** to define exit conditions based on indicators or other data that can be calculated in a vectorized manner. + 🚫 **Don't use** to customize exit conditions for each individual trade, or if trade data is necessary to make an exit decision. +* **`custom_exit()`** - Custom exit signal, called for every open trade every iteration until a trade is closed. + ✅ **Use** to customize exit conditions for each individual trade, or if trade data is necessary to make an exit decision. +* **`custom_stoploss()`** - Custom stoploss, called for every open trade every iteration until a trade is closed. The value returned here is also used for [stoploss on exchange](stoploss.md#stop-loss-on-exchangefreqtrade). + ✅ **Use** to customize the stoploss logic to set a dynamic stoploss based on trade data or other conditions. + 🚫 **Don't use** to exit a trade immediately based on a specific condition. Use `custom_exit()` for that purpose. +* **`custom_roi()`** - Custom ROI, called for every open trade every iteration until a trade is closed. + ✅ **Use** to customize the minimum ROI threshold to exit a trade dynamically based on profit or other conditions. + 🚫 **Don't use** to exit a trade immediately based on a specific condition. Use `custom_exit()` for that purpose. + 🚫 **Don't use** for static roi. Use `minimal_roi` for that purpose instead. From 5306fb3709d53f45f87fc57e2cef4ba2ea2c3312 Mon Sep 17 00:00:00 2001 From: Robert Davey Date: Sun, 25 May 2025 12:40:11 +0100 Subject: [PATCH 4/6] Add clarification to the exit table --- docs/includes/strategy-exit-comparisons.md | 25 +++++++++++----------- 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/docs/includes/strategy-exit-comparisons.md b/docs/includes/strategy-exit-comparisons.md index 9abbda7fa..fb6a3226d 100644 --- a/docs/includes/strategy-exit-comparisons.md +++ b/docs/includes/strategy-exit-comparisons.md @@ -1,17 +1,18 @@ ## Exit logic comparisons -Freqtrade allows your strategy to implement different exit logics. +Freqtrade allows your strategy to implement different exit logic using signal-based or callback-based functions. This section aims to compare each different section, helping you to choose the one that best fits your needs. -* **`populate_exit_trend()`** - Vectorized exit logic based on the dataframe - ✅ **Use** to define exit conditions based on indicators or other data that can be calculated in a vectorized manner. +* **`populate_exit_trend()`** - Vectorized signal-based exit logic using indicators in the main dataframe + ✅ **Use** to define exit signals based on indicators or other data that can be calculated in a vectorized manner. 🚫 **Don't use** to customize exit conditions for each individual trade, or if trade data is necessary to make an exit decision. -* **`custom_exit()`** - Custom exit signal, called for every open trade every iteration until a trade is closed. - ✅ **Use** to customize exit conditions for each individual trade, or if trade data is necessary to make an exit decision. -* **`custom_stoploss()`** - Custom stoploss, called for every open trade every iteration until a trade is closed. The value returned here is also used for [stoploss on exchange](stoploss.md#stop-loss-on-exchangefreqtrade). - ✅ **Use** to customize the stoploss logic to set a dynamic stoploss based on trade data or other conditions. - 🚫 **Don't use** to exit a trade immediately based on a specific condition. Use `custom_exit()` for that purpose. -* **`custom_roi()`** - Custom ROI, called for every open trade every iteration until a trade is closed. - ✅ **Use** to customize the minimum ROI threshold to exit a trade dynamically based on profit or other conditions. - 🚫 **Don't use** to exit a trade immediately based on a specific condition. Use `custom_exit()` for that purpose. - 🚫 **Don't use** for static roi. Use `minimal_roi` for that purpose instead. +* **`custom_exit()`** - Custom exit logic that will exit a position immediately, called for every open trade at every bot loop iteration until a trade is closed. + ✅ **Use** to specify exit conditions for each individual trade, or if trade data is necessary to make an exit decision, e.g. using profit data to exit. + 🚫 **Don't use** when you want to exit at candle close (use a `populate_exit_trend()` signal instead), or as a proxy for `custom_stoploss()`, and be aware that rate-based exits in backtesting can be inaccurate. +* **`custom_stoploss()`** - Custom trailing stoploss, called for every open trade every iteration until a trade is closed. The value returned here is also used for [stoploss on exchange](stoploss.md#stop-loss-on-exchangefreqtrade). + ✅ **Use** to customize the stoploss logic to set a dynamic stoploss based on trade data or other conditions. + 🚫 **Don't use** to exit a trade immediately based on a specific condition. Use `custom_exit()` for that purpose. +* **`custom_roi()`** - Custom ROI, called for every open trade every iteration until a trade is closed. + ✅ **Use** to specify a minimum ROI threshold ("take-profit") to exit a trade at this ROI level at some point within the trade duration, based on profit or other conditions. + 🚫 **Don't use** to exit a trade immediately based on a specific condition. Use `custom_exit()`. + 🚫 **Don't use** for static ROI. Use `minimal_roi`. From 1021c7a7afbf6405fb930e652eb69d8abe776782 Mon Sep 17 00:00:00 2001 From: Robert Davey Date: Sun, 25 May 2025 12:41:31 +0100 Subject: [PATCH 5/6] Minor typo --- docs/includes/strategy-exit-comparisons.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/includes/strategy-exit-comparisons.md b/docs/includes/strategy-exit-comparisons.md index fb6a3226d..d4d63fa77 100644 --- a/docs/includes/strategy-exit-comparisons.md +++ b/docs/includes/strategy-exit-comparisons.md @@ -1,7 +1,7 @@ ## Exit logic comparisons Freqtrade allows your strategy to implement different exit logic using signal-based or callback-based functions. -This section aims to compare each different section, helping you to choose the one that best fits your needs. +This section aims to compare each different function, helping you to choose the one that best fits your needs. * **`populate_exit_trend()`** - Vectorized signal-based exit logic using indicators in the main dataframe ✅ **Use** to define exit signals based on indicators or other data that can be calculated in a vectorized manner. From 0c13414f14e670672e534881a4f39569ae8555de Mon Sep 17 00:00:00 2001 From: Robert Davey Date: Sun, 25 May 2025 12:47:19 +0100 Subject: [PATCH 6/6] Slight rewording for clarity --- docs/includes/strategy-exit-comparisons.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/includes/strategy-exit-comparisons.md b/docs/includes/strategy-exit-comparisons.md index d4d63fa77..b677d503d 100644 --- a/docs/includes/strategy-exit-comparisons.md +++ b/docs/includes/strategy-exit-comparisons.md @@ -6,9 +6,9 @@ This section aims to compare each different function, helping you to choose the * **`populate_exit_trend()`** - Vectorized signal-based exit logic using indicators in the main dataframe ✅ **Use** to define exit signals based on indicators or other data that can be calculated in a vectorized manner. 🚫 **Don't use** to customize exit conditions for each individual trade, or if trade data is necessary to make an exit decision. -* **`custom_exit()`** - Custom exit logic that will exit a position immediately, called for every open trade at every bot loop iteration until a trade is closed. - ✅ **Use** to specify exit conditions for each individual trade, or if trade data is necessary to make an exit decision, e.g. using profit data to exit. - 🚫 **Don't use** when you want to exit at candle close (use a `populate_exit_trend()` signal instead), or as a proxy for `custom_stoploss()`, and be aware that rate-based exits in backtesting can be inaccurate. +* **`custom_exit()`** - Custom exit logic that will fully exit a trade immediately, called for every open trade at every bot loop iteration until a trade is closed. + ✅ **Use** to specify exit conditions for each individual trade (including any additional adjusted orders using `adjust_trade_position()`), or if trade data is necessary to make an exit decision, e.g. using profit data to exit. + 🚫 **Don't use** when you want to exit using vectorised indicator-based data (use a `populate_exit_trend()` signal instead), or as a proxy for `custom_stoploss()`, and be aware that rate-based exits in backtesting can be inaccurate. * **`custom_stoploss()`** - Custom trailing stoploss, called for every open trade every iteration until a trade is closed. The value returned here is also used for [stoploss on exchange](stoploss.md#stop-loss-on-exchangefreqtrade). ✅ **Use** to customize the stoploss logic to set a dynamic stoploss based on trade data or other conditions. 🚫 **Don't use** to exit a trade immediately based on a specific condition. Use `custom_exit()` for that purpose.