πChapter 5: "How to Optimize Strategy Parameters? Freqtrade Hyperopt Quick Start"
This article was produced by the Quantitative Trading Lab at https://www.itrade.icu. Visit for more benefits.
In strategy development, beyond constructing buy/sell logic, parameter settings often determine the final profit and risk ratio.
Freqtrade provides a powerful hyperopt function for automated search of optimal parameter combinations, greatly accelerating strategy iteration.
π§ 1. What is Hyperopt and When to Use It?
Hyperopt is an automated parameter optimization tool that can:
Find the best RSI threshold
Test optimal take-profit and stop-loss levels
Automatically try multiple parameter combinations β compare results β find the best configuration
β Suitable scenarios:
Strategies with multiple numerical parameters (e.g., RSI, MACD, Bollinger Band width, stop-loss ratio)
Searching for combinations that perform best over historical periods
Avoiding manual parameter tuning
π» 2. Dependency Installation
Hyperopt requires additional modules:
Tip
For full functionality including freqai or telegram support:
π 3. Basic Command and Parameters
--config
Configuration file path
--strategy
Strategy class to optimize
--hyperopt-loss
Optimization target function
--timerange
Backtest time range
--epochs
Number of iterations (more = more precise but slower)
--spaces
Which parameter spaces to optimize (default: buy, sell)
π― 4. Common Hyperopt Loss Functions
SharpeHyperOptLoss
Optimize Sharpe ratio
Balance risk and return
SortinoHyperOptLoss
Optimize Sortino ratio
Focus on downside risk
ProfitHyperOptLoss
Maximize total profit
Aggressive return-driven strategy
CalmarHyperOptLoss
Return / max drawdown ratio
Risk-aware preference
TrailingBuyHyperOptLoss
For trailing buy strategies
π§© 5. Defining Hyperparameters
Use the @parameter decorators in your strategy class:
Freqtrade will automatically search for the best combination within the defined ranges.
β οΈ 6. Common Pitfalls
β Overfitting
Short time frames or single-scenario data may lead to strategies that only perform well historically but fail live.
Recommendations:
Use longer time periods (6+ months)
Run Hyperopt multiple times β compare parameter convergence
Reserve part of data for forward testing
β Improper Loss Function
Optimizing only for profit may ignore risk, creating extreme strategies.
Recommendations:
Prefer Sharpe or Sortino as default
For low risk tolerance, use CalmarHyperOptLoss
β Large Search Space / Parameter Conflicts
Too many combinations increase search time and may cause conflicts.
Recommendations:
Limit parameters to 3β6
Use effective ranges (e.g., RSI from 10β50 instead of 1β100)
π οΈ 7. Example Strategy and Hyperopt Run
Example strategy:
Local run:
Docker run:
π― Adjustable Parameters
rsi_buy
IntParameter(10,50)
RSI buy threshold
stoploss_value
DecimalParameter(-0.1,-0.01)
Stop-loss ratio
Tips
Use
.valueto access actual parameter valuespace="buy"/"sell"defines Hyperopt search spacedefault=...is the manually set defaultRun backtesting first to confirm basic strategy logic
π 8. Hyperopt Evaluation Metrics
Common metrics:
Sharpe Ratio
Annualized return / volatility
Sortino Ratio
Annualized return / downside volatility
Calmar Ratio
Annualized return / max drawdown
Total Profit
Total profit
Drawdown
Max drawdown
Avg Trade Duration
Average trade duration
You can also define custom evaluation functions.
β
9. Recommended Workflow
π Summary
Freqtrade Hyperopt provides powerful support for parameter tuning, but correctly defining parameter ranges, loss functions, and data periods is key.
π The goal is not maximum profit, but stable, risk-resistant, and generalizable parameters.
Last updated