Optimization Best Practices
Avoiding Overfitting
Section titled “Avoiding Overfitting”Overfitting occurs when a strategy is too perfectly tuned to historical data and fails in live trading.
Signs of Overfitting
Section titled “Signs of Overfitting”- Unrealistically high returns (>100% annually)
- Very high win rate (>80%)
- Many parameters (>5)
- Isolated optimal values (no stable region)
- Poor out-of-sample performance
Prevention Strategies
Section titled “Prevention Strategies”-
Use Sufficient Data
- Minimum 5 years for daily strategies
- Include different market conditions
-
Limit Parameters
- Start with 2-3 parameters
- Add complexity only if justified
-
Use Walk-Forward Analysis
- Always validate out-of-sample
- Aim for >50% efficiency ratio
-
Look for Stable Regions
- Avoid isolated peaks
- Choose parameters where nearby values also work
Statistical Significance
Section titled “Statistical Significance”Minimum Trade Count
Section titled “Minimum Trade Count”- At least 30 trades for basic statistics
- 100+ trades for reliable estimates
Multiple Testing Correction
Section titled “Multiple Testing Correction”When testing many parameter combinations, some will look good by chance.
- 100 combinations → expect ~5 false positives at 95% confidence
- Use stricter thresholds for more combinations
Transaction Costs
Section titled “Transaction Costs”Always include realistic costs:
| Cost Type | Typical Value |
|---|---|
| Commission | $0.005/share or $1/trade |
| Slippage | 0.1% - 0.5% per trade |
| Spread | 0.05% - 0.2% |
Recommended Workflow
Section titled “Recommended Workflow”- Develop strategy with clear hypothesis
- Backtest on training data (60% of history)
- Optimize parameters on training data
- Validate on test data (40% of history)
- Walk-Forward for final validation
- Paper Trade before going live
Red Flags
Section titled “Red Flags”Stop and reconsider if you see:
- Need to re-optimize frequently
- Performance varies wildly by period
- Strategy only works on specific stocks
- You’re adding indicators to “fix” issues
Next Steps
Section titled “Next Steps”- API Examples - Automate your workflow
- Deployment - Go to production