📘Chapter 4: "How to Reliably Test Strategies? Complete Guide to Freqtrade Backtesting Command"
This article was produced by the Quantitative Trading Lab at https://www.itrade.icu. Visit for more benefits.
Backtesting is one of the most critical steps in strategy development. By simulating your strategy on historical market data, you can effectively evaluate its performance and determine whether it’s worth deploying in live trading.
This article provides a detailed guide to Freqtrade’s backtesting command, including usage, common parameters, data handling, result analysis, multi-processing acceleration, and Docker usage.
🔁 1. What is Backtesting and Why Is It Important?
Backtesting is the process of running your strategy on historical data as “simulated trades”, aiming to understand how the strategy would have performed in past markets.
A quality backtest can answer questions such as:
Is the risk/reward ratio reasonable?
Is the win rate stable enough?
Is the strategy overfitted? (May fail in live trading)
Which parameters most significantly affect profits?
🚀 2. Basic Backtesting Command Structure
freqtrade backtesting \
--config user_data/config.json \
--strategy MyStrategy \
--timeframe 15m \
--timerange 20220101-20230701Parameter Details
--config
Path to configuration file (includes pairs, timeframe, etc.)
--strategy
Strategy class name
--timeframe
Timeframe, e.g., 15m, 1h
--timerange
Backtesting period (format YYYYMMDD-YYYYMMDD)
Optional Parameters:
--export
Export detailed trade data as CSV
--stats-file
Output result statistics as JSON
--processes
Run multiple processes in parallel to improve speed
💡 3. Pre-Backtesting Preparation
Backtesting isn’t just running a command. Make sure to:
✅ Download historical data for the target timeframe:
✅ Place strategy files in
user_data/strategies/with correct class names.✅ Ensure
config.jsonis correctly set, including:Correct trading pairs
Correct exchange
stake_currencyset to USDT, BTC, etc.
🧪 4. Backtesting Output Explanation
After backtesting, Freqtrade will log information including:
Total profit
Strategy’s final net profit
Total trades
Number of trades executed
Win / loss ratio
Win rate (ratio of profitable trades)
Sharpe Ratio
Risk-adjusted return
Avg trade duration
Average holding period
Drawdown
Maximum drawdown
Profit factor
Profit factor (profit / loss)
🖼️ 5. Visual Backtesting (backtesting-show)
backtesting-show)Freqtrade provides backtesting-show to visualize buy/sell points and strategy behavior:
📍 Displays the strategy’s equity curve, trade markers, positions, etc.
🧩 6. Common Backtesting Issues
No trades executed
Strategy signals too strict, or missing data
Data not available
Data not downloaded or timerange does not cover
Indicators are NaN
Wrong indicator settings / not suitable for timeframe
Suspected overfitting
High backtest profit but live loss; use forward test
🧠 7. Multi-Processing for Faster Backtesting (--processes)
--processes)For multiple pairs or complex strategies, --processes can speed up backtesting:
🧪 Generally, set to half to all of CPU cores. For example, on an 8-core machine, set 4–8.
🐳 8. Backtesting in Docker
If running Freqtrade in Docker:
Ensure user_data/ is mounted to /quants/freqtrade/user_data/ in the container.
📊 9. Exporting Backtesting Results
To save detailed trades:
Or export strategy performance stats as JSON:
✅ 10. Recommended Analysis Metrics
Focus on these after backtesting:
Total profit: Core metric
Drawdown: Risk exposure
Win rate / Risk-reward ratio: Stability
Average trade profit: Value per trade
Profit factor: Worthiness of trading
Combine with chart analysis:
📌 Summary
Freqtrade’s backtesting system is powerful and flexible, suitable for a complete strategy research and validation workflow.
Download historical data
download-data
Write strategy class
new-strategy
Run backtest
backtesting
Visualize results
backtesting-show / plot-dataframe
Accelerate performance
--processes for multi-processing
Containerized use
Docker commands
Last updated