Repository: freqtrade/freqtrade

Issue:
Hyperopt Issue
## Step 1: Have you search for this issue before posting it?

If you have discovered a bug in the bot, please [search our issue tracker](https://github.com/freqtrade/freqtrade/issues?q=is%3Aissue). 
If it hasn't been reported, please create a new issue.

## Step 2: Describe your environment

  * Operating system: Ubuntu 18.04
  * Python Version: Python 3.7.4
  * CCXT version: ccxt==1.22.30
  * Branch: Develop
  * Last Commit ID: f8bb6a3e065f53695b5df28190b4dbf54623ea56
  
## Step 3: Describe the problem:

Hyperopt file was created out of the new template

error during hyperopt

### Steps to reproduce:

see log below

### Observed Results:

see log below

### Relevant code exceptions or logs:

  ```
 (.env) (base) andreas@andreas-G5-5590:~/freqtrade$ freqtrade hyperopt -c config_hyperopt.json --strategy BbandRsi_AP4 --hyperopt AP_hyperopt_BbandRSIV4 -e 2500 --spaces roi stoploss buy trailing --hyperopt-loss SharpeHyperOptLoss --timerange=20190101-20190901  --ticker-interval 15m
/home/andreas/freqtrade/.env/lib/python3.7/site-packages/sklearn/externals/joblib/__init__.py:15: FutureWarning: sklearn.externals.joblib is deprecated in 0.21 and will be removed in 0.23. Please import this functionality directly from joblib, which can be installed with: pip install joblib. If this warning is raised when loading pickled models, you may need to re-serialize those models with scikit-learn 0.21+.
  warnings.warn(msg, category=FutureWarning)
/home/andreas/freqtrade/.env/lib/python3.7/site-packages/sklearn/utils/deprecation.py:144: FutureWarning: The sklearn.metrics.scorer module is  deprecated in version 0.22 and will be removed in version 0.24. The corresponding classes / functions should instead be imported from sklearn.metrics. Anything that cannot be imported from sklearn.metrics is now part of the private API.
  warnings.warn(message, FutureWarning)
2020-02-04 10:00:25,160 - freqtrade.loggers - INFO - Verbosity set to 0
2020-02-04 10:00:25,160 - freqtrade.configuration.configuration - INFO - Parameter -i/--ticker-interval detected ... Using ticker_interval: 15m ...
2020-02-04 10:00:25,160 - freqtrade.configuration.configuration - INFO - Using max_open_trades: 5 ...
2020-02-04 10:00:25,160 - freqtrade.configuration.configuration - INFO - Parameter --timerange detected: 20190101-20190901 ...
2020-02-04 10:00:25,160 - freqtrade.configuration.configuration - INFO - Using user-data directory: /home/andreas/freqtrade/user_data ...
2020-02-04 10:00:25,161 - freqtrade.configuration.configuration - INFO - Using data directory: /home/andreas/freqtrade/user_data/data/binance ...
2020-02-04 10:00:25,161 - freqtrade.configuration.configuration - INFO - Overriding ticker interval with Command line argument
2020-02-04 10:00:25,161 - freqtrade.configuration.configuration - INFO - Using Hyperopt class name: AP_hyperopt_BbandRSIV4
2020-02-04 10:00:25,161 - freqtrade.configuration.configuration - INFO - Parameter --epochs detected ... Will run Hyperopt with for 2500 epochs ...
2020-02-04 10:00:25,161 - freqtrade.configuration.configuration - INFO - Parameter -s/--spaces detected: ['roi', 'stoploss', 'buy', 'trailing']
2020-02-04 10:00:25,161 - freqtrade.configuration.configuration - INFO - Parameter -j/--job-workers detected: -1
2020-02-04 10:00:25,161 - freqtrade.configuration.configuration - INFO - Parameter --min-trades detected: 1
2020-02-04 10:00:25,161 - freqtrade.configuration.configuration - INFO - Using Hyperopt loss class name: SharpeHyperOptLoss
2020-02-04 10:00:25,161 - freqtrade.configuration.check_exchange - INFO - Checking exchange...
2020-02-04 10:00:25,161 - freqtrade.configuration.check_exchange - INFO - Exchange "binance" is officially supported by the Freqtrade development team.
2020-02-04 10:00:25,161 - freqtrade.configuration.configuration - INFO - Using pairlist from configuration.
2020-02-04 10:00:25,161 - freqtrade.configuration.deprecated_settings - WARNING - DEPRECATED: The `experimental.use_sell_signal` setting is deprecated and will be removed in the next versions of Freqtrade. Please use the `ask_strategy.use_sell_signal` setting in your configuration instead.
2020-02-04 10:00:25,161 - freqtrade.configuration.deprecated_settings - WARNING - DEPRECATED: The `experimental.sell_profit_only` setting is deprecated and will be removed in the next versions of Freqtrade. Please use the `ask_strategy.sell_profit_only` setting in your configuration instead.
2020-02-04 10:00:25,161 - freqtrade.configuration.deprecated_settings - WARNING - DEPRECATED: The `experimental.ignore_roi_if_buy_signal` setting is deprecated and will be removed in the next versions of Freqtrade. Please use the `ask_strategy.ignore_roi_if_buy_signal` setting in your configuration instead.
2020-02-04 10:00:25,161 - freqtrade.configuration.config_validation - INFO - Validating configuration ...
2020-02-04 10:00:25,162 - freqtrade.commands.optimize_commands - INFO - Starting freqtrade in Hyperopt mode
2020-02-04 10:00:25,162 - filelock - INFO - Lock 140453659047312 acquired on /home/andreas/freqtrade/user_data/hyperopt.lock
2020-02-04 10:00:25,162 - freqtrade.exchange.exchange - INFO - Instance is running with dry_run enabled
2020-02-04 10:00:25,162 - freqtrade.exchange.exchange - INFO - Applying additional ccxt config: {'enableRateLimit': True}
2020-02-04 10:00:25,164 - freqtrade.exchange.exchange - INFO - Applying additional ccxt config: {'enableRateLimit': False}
2020-02-04 10:00:25,166 - freqtrade.exchange.exchange - INFO - Using Exchange "Binance"
2020-02-04 10:00:26,354 - freqtrade.resolvers.exchange_resolver - INFO - Using resolved exchange 'Binance'...
2020-02-04 10:00:26,371 - freqtrade.resolvers.iresolver - INFO - Using resolved strategy BbandRsi_AP4 from '/home/andreas/freqtrade/user_data/strategies/BbandRsi_AP4.py'...
2020-02-04 10:00:26,371 - freqtrade.resolvers.strategy_resolver - INFO - Override strategy 'ticker_interval' with value in config file: 15m.
2020-02-04 10:00:26,371 - freqtrade.resolvers.strategy_resolver - INFO - Override strategy 'order_types' with value in config file: {'buy': 'limit', 'sell': 'limit', 'stoploss': 'market', 'stoploss_on_exchange': False, 'stoploss_on_exchange_interval': 60}.
2020-02-04 10:00:26,372 - freqtrade.resolvers.strategy_resolver - INFO - Override strategy 'stake_currency' with value in config file: USDT.
2020-02-04 10:00:26,372 - freqtrade.resolvers.strategy_resolver - INFO - Override strategy 'stake_amount' with value in config file: 1000.
2020-02-04 10:00:26,372 - freqtrade.resolvers.strategy_resolver - INFO - Override strategy 'unfilledtimeout' with value in config file: {'buy': 10, 'sell': 30}.
2020-02-04 10:00:26,372 - freqtrade.resolvers.strategy_resolver - INFO - Override strategy 'use_sell_signal' with value in config file: True.
2020-02-04 10:00:26,372 - freqtrade.resolvers.strategy_resolver - INFO - Override strategy 'sell_profit_only' with value in config file: True.
2020-02-04 10:00:26,372 - freqtrade.resolvers.strategy_resolver - INFO - Override strategy 'ignore_roi_if_buy_signal' with value in config file: False.
2020-02-04 10:00:26,372 - freqtrade.resolvers.strategy_resolver - INFO - Strategy using minimal_roi: {'200': 0.02, '80': 0.03, '40': 0.04, '0': 0.05}
2020-02-04 10:00:26,372 - freqtrade.resolvers.strategy_resolver - INFO - Strategy using ticker_interval: 15m
2020-02-04 10:00:26,372 - freqtrade.resolvers.strategy_resolver - INFO - Strategy using stoploss: -0.15
2020-02-04 10:00:26,372 - freqtrade.resolvers.strategy_resolver - INFO - Strategy using trailing_stop: False
2020-02-04 10:00:26,372 - freqtrade.resolvers.strategy_resolver - INFO - Strategy using trailing_stop_positive_offset: 0.0
2020-02-04 10:00:26,372 - freqtrade.resolvers.strategy_resolver - INFO - Strategy using trailing_only_offset_is_reached: False
2020-02-04 10:00:26,372 - freqtrade.resolvers.strategy_resolver - INFO - Strategy using process_only_new_candles: False
2020-02-04 10:00:26,372 - freqtrade.resolvers.strategy_resolver - INFO - Strategy using order_types: {'buy': 'limit', 'sell': 'limit', 'stoploss': 'market', 'stoploss_on_exchange': False, 'stoploss_on_exchange_interval': 60}
2020-02-04 10:00:26,372 - freqtrade.resolvers.strategy_resolver - INFO - Strategy using order_time_in_force: {'buy': 'gtc', 'sell': 'gtc'}
2020-02-04 10:00:26,372 - freqtrade.resolvers.strategy_resolver - INFO - Strategy using stake_currency: USDT
2020-02-04 10:00:26,372 - freqtrade.resolvers.strategy_resolver - INFO - Strategy using stake_amount: 1000
2020-02-04 10:00:26,372 - freqtrade.resolvers.strategy_resolver - INFO - Strategy using startup_candle_count: 100
2020-02-04 10:00:26,372 - freqtrade.resolvers.strategy_resolver - INFO - Strategy using unfilledtimeout: {'buy': 10, 'sell': 30}
2020-02-04 10:00:26,372 - freqtrade.resolvers.strategy_resolver - INFO - Strategy using use_sell_signal: True
2020-02-04 10:00:26,372 - freqtrade.resolvers.strategy_resolver - INFO - Strategy using sell_profit_only: True
2020-02-04 10:00:26,372 - freqtrade.resolvers.strategy_resolver - INFO - Strategy using ignore_roi_if_buy_signal: False
2020-02-04 10:00:26,372 - freqtrade.configuration.config_validation - INFO - Validating configuration ...
2020-02-04 10:00:26,374 - freqtrade.resolvers.iresolver - INFO - Using resolved hyperopt AP_hyperopt_BbandRSIV4 from '/home/andreas/freqtrade/user_data/hyperopts/AP_hyperopt_BbandRSIV4.py'...
2020-02-04 10:00:26,377 - freqtrade.resolvers.iresolver - INFO - Using resolved hyperoptloss SharpeHyperOptLoss from '/home/andreas/freqtrade/freqtrade/optimize/hyperopt_loss_sharpe.py'...
2020-02-04 10:00:26,377 - freqtrade.optimize.hyperopt - INFO - Removing `/home/andreas/freqtrade/user_data/hyperopt_results/hyperopt_tickerdata.pkl`.
2020-02-04 10:00:26,377 - freqtrade.optimize.hyperopt - INFO - Using optimizer random state: 52085
2020-02-04 10:00:26,379 - freqtrade.data.history - INFO - Using indicator startup period: 100 ...
2020-02-04 10:00:26,484 - freqtrade.data.converter - INFO - Missing data fillup for XRP/USDT: before: 23328 - after: 23428
2020-02-04 10:00:26,620 - freqtrade.data.converter - INFO - Missing data fillup for TRX/USDT: before: 23328 - after: 23428
2020-02-04 10:00:26,779 - freqtrade.data.converter - INFO - Missing data fillup for IOTA/USDT: before: 23328 - after: 23428
2020-02-04 10:00:26,942 - freqtrade.data.converter - INFO - Missing data fillup for QTUM/USDT: before: 23328 - after: 23428
2020-02-04 10:00:27,064 - freqtrade.data.converter - INFO - Missing data fillup for ICX/USDT: before: 23328 - after: 23428
2020-02-04 10:00:27,068 - freqtrade.optimize.backtesting - INFO - Loading data from 2018-12-30T23:00:00+00:00 up to 2019-08-31T23:45:00+00:00 (244 days)..
2020-02-04 10:00:27,132 - freqtrade.optimize.hyperopt - INFO - Hyperopting with data from 2018-12-30T23:00:00+00:00 up to 2019-08-31T23:45:00+00:00 (244 days)..
2020-02-04 10:00:27,153 - freqtrade.optimize.hyperopt - INFO - Found 12 CPU cores. Let's make them scream!
2020-02-04 10:00:27,153 - freqtrade.optimize.hyperopt - INFO - Number of parallel jobs set as: -1
2020-02-04 10:00:27,167 - freqtrade.optimize.hyperopt - INFO - Effective number of parallel workers used: 12
/home/andreas/freqtrade/.env/lib/python3.7/site-packages/sklearn/externals/joblib/__init__.py:15: FutureWarning: sklearn.externals.joblib is deprecated in 0.21 and will be removed in 0.23. Please import this functionality directly from joblib, which can be installed with: pip install joblib. If this warning is raised when loading pickled models, you may need to re-serialize those models with scikit-learn 0.21+.
  warnings.warn(msg, category=FutureWarning)
/home/andreas/freqtrade/.env/lib/python3.7/site-packages/sklearn/externals/joblib/__init__.py:15: FutureWarning: sklearn.externals.joblib is deprecated in 0.21 and will be removed in 0.23. Please import this functionality directly from joblib, which can be installed with: pip install joblib. If this warning is raised when loading pickled models, you may need to re-serialize those models with scikit-learn 0.21+.
  warnings.warn(msg, category=FutureWarning)
/home/andreas/freqtrade/.env/lib/python3.7/site-packages/sklearn/externals/joblib/__init__.py:15: FutureWarning: sklearn.externals.joblib is deprecated in 0.21 and will be removed in 0.23. Please import this functionality directly from joblib, which can be installed with: pip install joblib. If this warning is raised when loading pickled models, you may need to re-serialize those models with scikit-learn 0.21+.
  warnings.warn(msg, category=FutureWarning)
/home/andreas/freqtrade/.env/lib/python3.7/site-packages/sklearn/externals/joblib/__init__.py:15: FutureWarning: sklearn.externals.joblib is deprecated in 0.21 and will be removed in 0.23. Please import this functionality directly from joblib, which can be installed with: pip install joblib. If this warning is raised when loading pickled models, you may need to re-serialize those models with scikit-learn 0.21+.
  warnings.warn(msg, category=FutureWarning)
/home/andreas/freqtrade/.env/lib/python3.7/site-packages/sklearn/utils/deprecation.py:144: FutureWarning: The sklearn.metrics.scorer module is  deprecated in version 0.22 and will be removed in version 0.24. The corresponding classes / functions should instead be imported from sklearn.metrics. Anything that cannot be imported from sklearn.metrics is now part of the private API.
  warnings.warn(message, FutureWarning)
/home/andreas/freqtrade/.env/lib/python3.7/site-packages/sklearn/utils/deprecation.py:144: FutureWarning: The sklearn.metrics.scorer module is  deprecated in version 0.22 and will be removed in version 0.24. The corresponding classes / functions should instead be imported from sklearn.metrics. Anything that cannot be imported from sklearn.metrics is now part of the private API.
  warnings.warn(message, FutureWarning)
/home/andreas/freqtrade/.env/lib/python3.7/site-packages/sklearn/utils/deprecation.py:144: FutureWarning: The sklearn.metrics.scorer module is  deprecated in version 0.22 and will be removed in version 0.24. The corresponding classes / functions should instead be imported from sklearn.metrics. Anything that cannot be imported from sklearn.metrics is now part of the private API.
  warnings.warn(message, FutureWarning)
/home/andreas/freqtrade/.env/lib/python3.7/site-packages/sklearn/utils/deprecation.py:144: FutureWarning: The sklearn.metrics.scorer module is  deprecated in version 0.22 and will be removed in version 0.24. The corresponding classes / functions should instead be imported from sklearn.metrics. Anything that cannot be imported from sklearn.metrics is now part of the private API.
  warnings.warn(message, FutureWarning)
/home/andreas/freqtrade/.env/lib/python3.7/site-packages/sklearn/externals/joblib/__init__.py:15: FutureWarning: sklearn.externals.joblib is deprecated in 0.21 and will be removed in 0.23. Please import this functionality directly from joblib, which can be installed with: pip install joblib. If this warning is raised when loading pickled models, you may need to re-serialize those models with scikit-learn 0.21+.
  warnings.warn(msg, category=FutureWarning)
/home/andreas/freqtrade/.env/lib/python3.7/site-packages/sklearn/utils/deprecation.py:144: FutureWarning: The sklearn.metrics.scorer module is  deprecated in version 0.22 and will be removed in version 0.24. The corresponding classes / functions should instead be imported from sklearn.metrics. Anything that cannot be imported from sklearn.metrics is now part of the private API.
  warnings.warn(message, FutureWarning)
/home/andreas/freqtrade/.env/lib/python3.7/site-packages/sklearn/externals/joblib/__init__.py:15: FutureWarning: sklearn.externals.joblib is deprecated in 0.21 and will be removed in 0.23. Please import this functionality directly from joblib, which can be installed with: pip install joblib. If this warning is raised when loading pickled models, you may need to re-serialize those models with scikit-learn 0.21+.
  warnings.warn(msg, category=FutureWarning)
/home/andreas/freqtrade/.env/lib/python3.7/site-packages/sklearn/utils/deprecation.py:144: FutureWarning: The sklearn.metrics.scorer module is  deprecated in version 0.22 and will be removed in version 0.24. The corresponding classes / functions should instead be imported from sklearn.metrics. Anything that cannot be imported from sklearn.metrics is now part of the private API.
  warnings.warn(message, FutureWarning)
/home/andreas/freqtrade/.env/lib/python3.7/site-packages/sklearn/externals/joblib/__init__.py:15: FutureWarning: sklearn.externals.joblib is deprecated in 0.21 and will be removed in 0.23. Please import this functionality directly from joblib, which can be installed with: pip install joblib. If this warning is raised when loading pickled models, you may need to re-serialize those models with scikit-learn 0.21+.
  warnings.warn(msg, category=FutureWarning)
/home/andreas/freqtrade/.env/lib/python3.7/site-packages/sklearn/externals/joblib/__init__.py:15: FutureWarning: sklearn.externals.joblib is deprecated in 0.21 and will be removed in 0.23. Please import this functionality directly from joblib, which can be installed with: pip install joblib. If this warning is raised when loading pickled models, you may need to re-serialize those models with scikit-learn 0.21+.
  warnings.warn(msg, category=FutureWarning)
/home/andreas/freqtrade/.env/lib/python3.7/site-packages/sklearn/utils/deprecation.py:144: FutureWarning: The sklearn.metrics.scorer module is  deprecated in version 0.22 and will be removed in version 0.24. The corresponding classes / functions should instead be imported from sklearn.metrics. Anything that cannot be imported from sklearn.metrics is now part of the private API.
  warnings.warn(message, FutureWarning)
/home/andreas/freqtrade/.env/lib/python3.7/site-packages/sklearn/utils/deprecation.py:144: FutureWarning: The sklearn.metrics.scorer module is  deprecated in version 0.22 and will be removed in version 0.24. The corresponding classes / functions should instead be imported from sklearn.metrics. Anything that cannot be imported from sklearn.metrics is now part of the private API.
  warnings.warn(message, FutureWarning)
/home/andreas/freqtrade/.env/lib/python3.7/site-packages/sklearn/externals/joblib/__init__.py:15: FutureWarning: sklearn.externals.joblib is deprecated in 0.21 and will be removed in 0.23. Please import this functionality directly from joblib, which can be installed with: pip install joblib. If this warning is raised when loading pickled models, you may need to re-serialize those models with scikit-learn 0.21+.
  warnings.warn(msg, category=FutureWarning)
/home/andreas/freqtrade/.env/lib/python3.7/site-packages/sklearn/externals/joblib/__init__.py:15: FutureWarning: sklearn.externals.joblib is deprecated in 0.21 and will be removed in 0.23. Please import this functionality directly from joblib, which can be installed with: pip install joblib. If this warning is raised when loading pickled models, you may need to re-serialize those models with scikit-learn 0.21+.
  warnings.warn(msg, category=FutureWarning)
/home/andreas/freqtrade/.env/lib/python3.7/site-packages/sklearn/utils/deprecation.py:144: FutureWarning: The sklearn.metrics.scorer module is  deprecated in version 0.22 and will be removed in version 0.24. The corresponding classes / functions should instead be imported from sklearn.metrics. Anything that cannot be imported from sklearn.metrics is now part of the private API.
  warnings.warn(message, FutureWarning)
/home/andreas/freqtrade/.env/lib/python3.7/site-packages/sklearn/utils/deprecation.py:144: FutureWarning: The sklearn.metrics.scorer module is  deprecated in version 0.22 and will be removed in version 0.24. The corresponding classes / functions should instead be imported from sklearn.metrics. Anything that cannot be imported from sklearn.metrics is now part of the private API.
  warnings.warn(message, FutureWarning)
2020-02-04 10:00:29,049 - freqtrade - ERROR - Fatal exception!
joblib.externals.loky.process_executor._RemoteTraceback: 
"""
Traceback (most recent call last):
  File "/home/andreas/freqtrade/.env/lib/python3.7/site-packages/joblib/externals/loky/process_executor.py", line 418, in _process_worker
    r = call_item()
  File "/home/andreas/freqtrade/.env/lib/python3.7/site-packages/joblib/externals/loky/process_executor.py", line 272, in __call__
    return self.fn(*self.args, **self.kwargs)
  File "/home/andreas/freqtrade/.env/lib/python3.7/site-packages/joblib/_parallel_backends.py", line 608, in __call__
    return self.func(*args, **kwargs)
  File "/home/andreas/freqtrade/.env/lib/python3.7/site-packages/joblib/parallel.py", line 256, in __call__
    for func, args, kwargs in self.items]
  File "/home/andreas/freqtrade/.env/lib/python3.7/site-packages/joblib/parallel.py", line 256, in <listcomp>
    for func, args, kwargs in self.items]
  File "/home/andreas/freqtrade/.env/lib/python3.7/site-packages/joblib/externals/loky/cloudpickle_wrapper.py", line 38, in __call__
    return self._obj(*args, **kwargs)
  File "/home/andreas/freqtrade/freqtrade/optimize/hyperopt.py", line 345, in generate_optimizer
    params_details = self._get_params_details(params_dict)
  File "/home/andreas/freqtrade/freqtrade/optimize/hyperopt.py", line 188, in _get_params_details
    result['trailing'] = self.custom_hyperopt.generate_trailing_params(params)
  File "/home/andreas/freqtrade/freqtrade/optimize/hyperopt_interface.py", line 184, in generate_trailing_params
    params['trailing_stop_positive_offset_p1']),
KeyError: 'trailing_stop_positive_offset_p1'
"""

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/home/andreas/freqtrade/freqtrade/main.py", line 36, in main
    return_code = args['func'](args)
  File "/home/andreas/freqtrade/freqtrade/commands/optimize_commands.py", line 76, in start_hyperopt
    hyperopt.start()
  File "/home/andreas/freqtrade/freqtrade/optimize/hyperopt.py", line 523, in start
    f_val = self.run_optimizer_parallel(parallel, asked, i)
  File "/home/andreas/freqtrade/freqtrade/optimize/hyperopt.py", line 461, in run_optimizer_parallel
    wrap_non_picklable_objects(self.generate_optimizer))(v, i) for v in asked)
  File "/home/andreas/freqtrade/.env/lib/python3.7/site-packages/joblib/parallel.py", line 1017, in __call__
    self.retrieve()
  File "/home/andreas/freqtrade/.env/lib/python3.7/site-packages/joblib/parallel.py", line 909, in retrieve
    self._output.extend(job.get(timeout=self.timeout))
  File "/home/andreas/freqtrade/.env/lib/python3.7/site-packages/joblib/_parallel_backends.py", line 562, in wrap_future_result
    return future.result(timeout=timeout)
  File "/home/andreas/anaconda3/lib/python3.7/concurrent/futures/_base.py", line 435, in result
    return self.__get_result()
  File "/home/andreas/anaconda3/lib/python3.7/concurrent/futures/_base.py", line 384, in __get_result
    raise self._exception
KeyError: 'trailing_stop_positive_offset_p1'

  ```



Discussion:
@Prossi79 Is there a particular reason why you're using trailing_stop_positive_offset_p1 as a param in AP_hyperopt_BbandRSIV4? Using **--spaces trailing** should be enough to optimize trailing parameters for you. You don't have to specify them in the AP_hyperopt_BbandRSIV4 file.
I like to hyperopt the stoploss and trailing space, thats the code out of AP_hyperopt_BbandRSIV4 file:

    @staticmethod
    def stoploss_space() -> List[Dimension]:
        """
        Stoploss Value to search

        Override it if you need some different range for the parameter in the
        'stoploss' optimization hyperspace.
        """
        return [
            Real(-0.5, -0.02, name='stoploss'),
        ]

    @staticmethod
    def trailing_space() -> List[Dimension]:
        """
        Create a trailing stoploss space.

        You may override it in your custom Hyperopt class.
        """
        return [
            # It was decided to always set trailing_stop is to True if the 'trailing' hyperspace
            # is used. Otherwise hyperopt will vary other parameters that won't have effect if
            # trailing_stop is set False.
            # This parameter is included into the hyperspace dimensions rather than assigning
            # it explicitly in the code in order to have it printed in the results along with
            # other 'trailing' hyperspace parameters.
            Categorical([True], name='trailing_stop'),

            Real(0.02, 0.35, name='trailing_stop_positive'),
            Real(0.01, 0.1, name='trailing_stop_positive_offset'),
            Categorical([True, False], name='trailing_only_offset_is_reached'),
        ]

Yeah, the sample in sample_hyperopt_advanced.py was not aligned with the changes made into hyperopt_interface.py, I'll fix it, thanks!


Resolving patch:
diff --git a/freqtrade/optimize/hyperopt_interface.py b/freqtrade/optimize/hyperopt_interface.py
--- a/freqtrade/optimize/hyperopt_interface.py
+++ b/freqtrade/optimize/hyperopt_interface.py
@@ -207,7 +207,7 @@ def trailing_space() -> List[Dimension]:
             # so this intermediate parameter is used as the value of the difference between
             # them. The value of the 'trailing_stop_positive_offset' is constructed in the
             # generate_trailing_params() method.
-            # # This is similar to the hyperspace dimensions used for constructing the ROI tables.
+            # This is similar to the hyperspace dimensions used for constructing the ROI tables.
             Real(0.001, 0.1, name='trailing_stop_positive_offset_p1'),
 
             Categorical([True, False], name='trailing_only_offset_is_reached'),
diff --git a/freqtrade/templates/sample_hyperopt_advanced.py b/freqtrade/templates/sample_hyperopt_advanced.py
--- a/freqtrade/templates/sample_hyperopt_advanced.py
+++ b/freqtrade/templates/sample_hyperopt_advanced.py
@@ -230,7 +230,7 @@ def stoploss_space() -> List[Dimension]:
         'stoploss' optimization hyperspace.
         """
         return [
-            Real(-0.5, -0.02, name='stoploss'),
+            Real(-0.35, -0.02, name='stoploss'),
         ]
 
     @staticmethod
@@ -249,8 +249,15 @@ def trailing_space() -> List[Dimension]:
             # other 'trailing' hyperspace parameters.
             Categorical([True], name='trailing_stop'),
 
-            Real(0.02, 0.35, name='trailing_stop_positive'),
-            Real(0.01, 0.1, name='trailing_stop_positive_offset'),
+            Real(0.01, 0.35, name='trailing_stop_positive'),
+
+            # 'trailing_stop_positive_offset' should be greater than 'trailing_stop_positive',
+            # so this intermediate parameter is used as the value of the difference between
+            # them. The value of the 'trailing_stop_positive_offset' is constructed in the
+            # generate_trailing_params() method.
+            # This is similar to the hyperspace dimensions used for constructing the ROI tables.
+            Real(0.001, 0.1, name='trailing_stop_positive_offset_p1'),
+
             Categorical([True, False], name='trailing_only_offset_is_reached'),
         ]
 


Test patch: