Lesson 7: Multi-Timeframe Backtesting
β± Duration: 2 hours
π― Learning Objectives: Understand the impact of timeframes on strategies
π Difficulty: ββ Backtesting practical
π Course Overview
The same strategy can perform very differently on different timeframes. Through practical testing, this lesson will help you understand timeframe selection principles and find the most suitable time period for your strategy.
7.1 Timeframe Selection Principles
Three Core Principles
Principle 1: Trading Style Match
Your time investment β determines timeframe
Full-time monitoring (8h+/day) β 1m-5m (ultra-short term)
Part-time monitoring (2-4h/day) β 15m-1h (short term)
Occasional checking (<1h/day) β 4h-1d (swing trading)
Fully automated β any timeframe
Principle 2: Risk Tolerance
Single trade volatility increases with timeframe
1m: Single trade volatility 0.1-0.5% β Low risk, low pressure
5m: Single trade volatility 0.3-1% β Moderate risk
1h: Single trade volatility 1-3% β Higher risk
1d: Single trade volatility 3-10% β High risk, high psychological pressure
Principle 3: Strategy Type Adaptation
Trend following strategies β Long timeframes (1h-1d)
Mean reversion strategies β Medium-short timeframes (5m-1h)
Breakout strategies β Medium timeframes (15m-4h)
High-frequency arbitrage β Ultra-short timeframes (1m-5m)
Timeframe Feature Comparison
Timeframe | Signal Frequency | Signal Quality | Fee Percentage | Data Requirements | Execution Requirements |
---|---|---|---|---|---|
1m | Extremely High | Low (lots of noise) | Very High (15-30%) | Massive | Millisecond-level |
5m | High | Medium-Low | High (8-15%) | Large | Second-level |
15m | Medium-High | Medium | Moderate (5-10%) | Medium | Minute-level |
1h | Medium | Medium-High | Low (2-5%) | Moderate | Hour-level |
4h | Low | High | Very Low (< 2%) | Small | Hour-level |
1d | Very Low | Very High | Extremely Low (< 1%) | Very Small | Day-level |
7.2 Characteristics of Different Timeframes
1. Ultra-Short Term (1m - 5m)
Detailed Features
Advantages:
- β Extremely many trading opportunities (tens to hundreds of trades daily)
- β Fast capital turnover, high utilization
- β Small single trade risk (small stop loss)
- β Quick strategy validation (see results in days)
Disadvantages:
- β Many noise signals, frequent false breakouts
- β High fee costs (may consume 30-50% of profits)
- β High execution speed requirements (1-second delay can affect returns)
- β Large data volume (1 year of 1m data > 500MB/pair)
- β Slow backtesting speed
- β Significant slippage impact
Fee Impact Case Study
5m timeframe, 30-day backtest:
Trade Count: 150 trades
Average Profit per Trade: +0.6%
Fees: 0.2% Γ 150 = 30%
Gross Profit: 0.6% Γ 150 = 90%
Net Profit: 90% - 30% = 60%
Fee erosion: 33.3% of profits!
Suitable For
- Full-time traders
- Those with exchange fee discounts (VIP users)
- High-frequency algorithmic trading systems
- Those well-prepared for latency and execution
Risk Warning
β οΈ Not recommended for beginners: Good backtesting performance β Good live performance (slippage and latency will significantly reduce returns)
2. Short Term (15m - 1h)
Detailed Features
Advantages:
- β Good signal quality (noise filtered)
- β Moderate trading frequency (5-20 trades daily)
- β Controllable fee impact (5-10%)
- β Moderate data volume, fast backtesting
- β Relaxed execution requirements (few minutes of delay acceptable)
- β Suitable for beginners to practice
Disadvantages:
- β οΈ Still requires regular monitoring (cannot be fully automated)
- β οΈ Need to endure intraday volatility
- β οΈ Overnight risk (1h may span overnight)
Best Practices
15m timeframe:
- Each candle is 15 minutes
- 96 candles daily
- Suitable for intraday trading (8:00 AM - 12:00 AM)
- Typical holding time: 1-6 hours
1h timeframe:
- Each candle is 1 hour
- 24 candles daily
- Suitable for short swing trading
- Typical holding time: 4-24 hours
Fee Impact Case Study
1h timeframe, 30-day backtest:
Trade Count: 40 trades
Average Profit per Trade: +1.5%
Fees: 0.2% Γ 40 = 8%
Gross Profit: 1.5% Γ 40 = 60%
Net Profit: 60% - 8% = 52%
Fee erosion: 13.3% of profits (acceptable)
Suitable For
- Quantitative trading beginners (highly recommended)
- Part-time traders (2-4 hours daily)
- Those who want to see quick results
- Balance returns and risks
3. Medium-Long Term (4h - 1d)
Detailed Features
Advantages:
- β High signal quality (clear major trends)
- β Extremely low fee percentage (< 2%)
- β High single trade returns (average 3-10%)
- β No need for frequent monitoring
- β Small slippage impact
- β Low psychological pressure (no need to watch screen)
Disadvantages:
- β Few trading opportunities (few trades weekly)
- β Low capital utilization (occupied for long periods)
- β Large single trade volatility (need larger stop loss space)
- β Overnight risk (weekend, holiday risks)
- β Long validation period (need months of data)
Overnight Risk Analysis
Risk Sources:
- US Market Close Impact: US market crashes β Crypto follows
- Asian Opening Volatility: High volatility during China market opening hours
- Sudden News: Regulatory policies, hacker attacks, exchange suspensions
- Weekend Gaps: Price jumps from Friday close to Monday open
Countermeasures:
# Force close before weekend (advanced usage)
def custom_exit(self, pair, trade, current_time, **kwargs):
# Force close after 22:00 on Friday
if current_time.weekday() == 4 and current_time.hour >= 22:
return 'weekend_exit'
Suitable For
- Part-time traders (< 1 hour daily)
- Those who dislike frequent operations
- Those with large capital (can handle single trade volatility)
- Long-term investment mindset
7.3 Timeframe and Trading Style Matching
Trading Style Classification
1. Day Traders
Features:
- Open and close positions same day
- No overnight holding
- 5-20 trades daily
Recommended Timeframes: 5m - 15m
Recommended Strategies: Mean reversion, breakout strategies
Key Settings:
# Ensure no overnight holding (set in strategy)
minimal_roi = {
"0": 0.02, # 2% immediate take profit
"60": 0.01, # 1% take profit after 1 hour
"300": 0 # Close position after 5 hours
}
2. Swing Traders
Features:
- Hold positions for days to weeks
- Capture medium-term trends
- 2-10 trades weekly
Recommended Timeframes: 1h - 4h
Recommended Strategies: Trend following, momentum strategies
Key Settings:
minimal_roi = {
"0": 0.10, # 10% immediate take profit
"1440": 0.05, # 5% take profit after 1 day
"4320": 0.02 # 2% take profit after 3 days
}
3. Trend Traders
Features:
- Hold positions for weeks to months
- Capture major trends
- 1-5 trades monthly
Recommended Timeframes: 1d
Recommended Strategies: Trend following, breakout strategies
Key Settings:
minimal_roi = {
"0": 0.30, # 30% immediate take profit
"10080": 0.15, # 15% take profit after 1 week
"43200": 0.08 # 8% take profit after 1 month
}
Matching Test Table
Your Situation | Recommended Timeframe | Expected Trading Frequency |
---|---|---|
Can monitor 6h+ daily | 5m - 15m | 10-50 times/day |
Can check 2-4h daily | 15m - 1h | 5-20 times/day |
Can only check 1h daily | 1h - 4h | 2-10 times/day |
Only check few times weekly | 4h - 1d | 5-20 times/month |
Fully automated | Based on strategy type | Any |
7.4 Multi-Timeframe Comparative Analysis
Practical Testing Process
Step 1: Prepare Data
# Download multiple timeframe data
freqtrade download-data \
-c config.json \
--pairs BTC/USDT \
--days 90 \
--timeframes 5m 15m 1h 4h 1d
Step 2: Batch Backtesting
# Test 5m
freqtrade backtesting -c config.json --strategy Strategy001 --timeframe 5m --timerange 20250701-20250930
# Test 15m
freqtrade backtesting -c config.json --strategy Strategy001 --timeframe 15m --timerange 20250701-20250930
# Test 1h
freqtrade backtesting -c config.json --strategy Strategy001 --timeframe 1h --timerange 20250701-20250930
# Test 1d
freqtrade backtesting -c config.json --strategy Strategy001 --timeframe 1d --timerange 20250701-20250930
Step 3: Use Shell Script for Batch Testing
Create test_timeframes.sh
:
#!/bin/bash
STRATEGY="Strategy001"
CONFIG="config.json"
TIMERANGE="20250701-20250930"
for TIMEFRAME in 5m 15m 1h 4h 1d
do
echo "========================================"
echo "Testing $STRATEGY on $TIMEFRAME"
echo "========================================"
freqtrade backtesting \
-c $CONFIG \
--strategy $STRATEGY \
--timeframe $TIMEFRAME \
--timerange $TIMERANGE
echo ""
echo "Finished $TIMEFRAME, press Enter to continue..."
read
done
echo "All tests completed!"
Run script:
chmod +x test_timeframes.sh
./test_timeframes.sh
Comparison Analysis Template
Create comparison table to record results:
Metric | 5m | 15m | 1h | 4h | 1d |
---|---|---|---|---|---|
Trade Count | |||||
Win Rate % | |||||
Total Profit % | |||||
Avg Profit % | |||||
Max Drawdown % | |||||
Sharpe Ratio | |||||
ROI Exit % | |||||
Stop Loss Exit % | |||||
Avg Holding Time | |||||
Fee % |
Real Case Analysis
Assume Strategy001 performance on different timeframes:
Timeframe | Trade Count | Win Rate | Total Profit | Avg Profit | Max Drawdown | Sharpe | Fee % | Rating |
---|---|---|---|---|---|---|---|---|
5m | 247 | 68% | +12.5% | +0.05% | -8.2% | 1.85 | 19.8% | ββ |
15m | 89 | 75% | +18.3% | +0.21% | -6.5% | 2.65 | 9.7% | ββββ |
1h | 31 | 81% | +15.7% | +0.51% | -4.8% | 3.12 | 3.9% | βββββ |
4h | 12 | 83% | +9.2% | +0.77% | -3.2% | 2.88 | 2.6% | ββββ |
1d | 4 | 100% | +6.8% | +1.70% | -2.1% | 3.45 | 1.2% | βββ |
Analysis Conclusions
5m timeframe:
- β Trading too frequent (247 trades)
- β Serious fee erosion (19.8%)
- β Extremely low average profit (0.05%)
- β Low Sharpe Ratio (1.85)
- Conclusion: Not suitable for this strategy
15m timeframe:
- β Moderate trade count (89 trades)
- β Good win rate (75%)
- β High total profit (18.3%)
- β Controllable fees (9.7%)
- β Excellent Sharpe Ratio (2.65)
- Conclusion: Very suitable, balances returns and frequency
1h timeframe:
- β Highest win rate (81%)
- β Highest Sharpe Ratio (3.12)
- β Smallest drawdown (4.8%)
- β Extremely low fees (3.9%)
- β οΈ Total profit slightly lower than 15m
- Conclusion: Best choice, optimal risk-return ratio
4h timeframe:
- β High win rate (83%)
- β High average profit (0.77%)
- β οΈ Few trades (12 trades, small sample)
- β οΈ Lower total profit (9.2%)
- Conclusion: Optional, but needs longer validation
1d timeframe:
- β 100% win rate (4 wins, 0 losses)
- β Highest average profit (1.70%)
- β Too few trades (only 4 trades)
- β Insufficient sample, not representative
- Conclusion: Needs longer validation (at least 1 year of data)
Optimal Timeframe Judgment Criteria
Comprehensive Scoring Formula:
Total Score = Total Profit(30%) + Sharpe(25%) + Win Rate(20%) + Trade Count Reasonableness(15%) + Fee Percentage(10%)
Applied to Case:
15m: (18.3Γ0.3) + (2.65Γ10Γ0.25) + (75Γ0.2) + (100Γ0.15) + ((100-9.7)Γ0.1) = 5.49 + 6.63 + 15 + 15 + 9.03 = 51.15
1h: (15.7Γ0.3) + (3.12Γ10Γ0.25) + (81Γ0.2) + (90Γ0.15) + ((100-3.9)Γ0.1) = 4.71 + 7.80 + 16.2 + 13.5 + 9.61 = 51.82 β
Conclusion: 1h is slightly better
π‘ Practical Tasks
Task 1: Data Preparation
# Download BTC/USDT multiple timeframe data
conda activate freqtrade
freqtrade download-data \
-c config.json \
--pairs BTC/USDT \
--days 90 \
--timeframes 5m 15m 1h 1d
Task 2: Batch Backtesting
Choose a strategy (recommend Strategy001), test 4 timeframes:
# 5m
freqtrade backtesting -c config.json --strategy Strategy001 --timeframe 5m --timerange 20250701-20250930
# 15m
freqtrade backtesting -c config.json --strategy Strategy001 --timeframe 15m --timerange 20250701-20250930
# 1h
freqtrade backtesting -c config.json --strategy Strategy001 --timeframe 1h --timerange 20250701-20250930
# 1d
freqtrade backtesting -c config.json --strategy Strategy001 --timeframe 1d --timerange 20250701-20250930
Task 3: Create Comparison Table
Create Excel table, record the following information:
Metric | 5m | 15m | 1h | 1d |
---|---|---|---|---|
Trade Count | ? | ? | ? | ? |
Win Rate | ? | ? | ? | ? |
Total Profit % | ? | ? | ? | ? |
Avg Profit % | ? | ? | ? | ? |
Max Drawdown % | ? | ? | ? | ? |
Sharpe Ratio | ? | ? | ? | ? |
Avg Holding Time | ? | ? | ? | ? |
Fee % | ? | ? | ? | ? |
Task 4: Find Optimal Timeframe
Based on your comparison table, answer the following questions:
- Which timeframe has the highest total profit?
- Which timeframe has the highest Sharpe Ratio?
- Which timeframe has the smallest drawdown?
- Which timeframe has the lowest fee percentage?
- Overall, which timeframe do you think is most suitable for this strategy?
Task 5: Write Analysis Report
Write a 200-300 word analysis report:
Report Template:
Strategy Name: ___________
Test Time Range: ___________
Test Trading Pair: ___________
Timeframe Comparison Analysis:
- 5m Performance: ___________ (Advantages/Disadvantages)
- 15m Performance: ___________ (Advantages/Disadvantages)
- 1h Performance: ___________ (Advantages/Disadvantages)
- 1d Performance: ___________ (Advantages/Disadvantages)
Optimal Choice: ___________
Reasons for Choice: ___________
Risk Warnings: ___________
π Knowledge Check
Basic Questions
- Why is the fee percentage high for 5m timeframe?
- What is the main risk of 1d timeframe?
- If you can only check charts for 1 hour daily, what timeframe should you choose?
Answers
- Many trades, each trade requires paying fees, cumulative percentage is high
- Overnight risk (weekend gaps, sudden news) and small sample size (long validation period)
- 1h or 4h, so you don't need frequent monitoring but can still capture good trading opportunities
Advanced Questions
- Why does the same strategy perform very differently on different timeframes?
- How to determine if the sample size for timeframe testing is sufficient?
- If short-term backtesting performs well, does it mean live trading will also be good?
Thought Questions
- If a strategy performs poorly on all timeframes, what does it indicate?
- Can you run the same strategy on multiple timeframes simultaneously?
- What are the advantages of multi-timeframe combination strategies (e.g., use 1h to confirm trend, 5m for entry)?
π§ Common Problems and Solutions
Problem 1: Insufficient data error during backtesting
Error Message:
No data found for timeframe 1d in the specified timerange
Solution:
# Confirm data downloaded for that timeframe
freqtrade list-data -c config.json
# Redownload
freqtrade download-data -c config.json --timeframes 1d --days 90
Problem 2: Only few trades on 1d timeframe
Causes:
- Sample period too short (90 days = 90 1d candles)
- Strategy itself has low trading frequency
Solution:
# Download longer period data (1-2 years)
freqtrade download-data -c config.json --timeframes 1d --days 730
Problem 3: Large variation in results across timeframes
Causes:
- Market environment changes
- Strategy overfitting
- Insufficient sample size
Solutions:
- Test longer time ranges
- Test different market environments (bull, bear, sideways)
- Conduct out-of-sample testing
π Timeframe Selection Decision Tree
Start
β
ββ Can you monitor full-time?
β ββ Yes β Do you have fee discounts?
β β ββ Yes β 5m (high-frequency trading)
β β ββ No β 15m (intraday trading)
β β
β ββ No β How many times can you check daily?
β ββ 2-4 times β 1h (short swing)
β ββ 1-2 times β 4h (medium swing)
β ββ < 1 time β 1d (long swing)
β
ββ Your risk tolerance?
ββ Low β Choose long timeframes (1h-1d)
ββ Medium β Choose medium timeframes (15m-1h)
ββ High β Choose short timeframes (5m-15m)
π Reference Materials
Supporting Documentation
- π TESTING_GUIDE.md - Different timeframe backtesting
- π STRATEGY_SELECTION_GUIDE.md - Strategy selection guide
Recommended Reading
π Key Points Summary
- No best timeframe, only most suitable one
- Short timeframe = High frequency + High fees + High noise
- Long timeframe = Low frequency + Low fees + High quality
- Beginner recommended 15m-1h: Balance returns, risks, and operation frequency
- Sample size is important: 1d needs at least 1 year of data
- Good backtesting β Good live performance: Short-term strategies heavily affected by slippage
β‘οΈ Next Lesson Preview
Lesson 8: Strategy Batch Comparison
In the next lesson, we will:
- Learn methods for batch backtesting multiple strategies
- Quickly compare strategy performance
- Master strategy selection decision tree
- Create strategy recommendation list
Preparation:
- β Ensure you have 5+ strategies available
- β Select testing timeframe (recommend 15m or 1h)
- β Prepare 90+ days of data
π― Learning Check Standards:
- β Can independently test strategy performance on multiple timeframes
- β Understand advantages and disadvantages of different timeframes
- β Can choose suitable timeframe based on your situation
- β Can create timeframe comparison analysis table
After completing these tasks, you have mastered the core skills of timeframe selection! Ready to move on to strategy comparison learning! π
Top comments (0)