TPE (Bayesian)
A smart sampler that learns from every cycle. The modern default.
- Quality
- High
- Speed
- Fast
- Budget
- O(N)
How it works
TPE stands for Tree-structured Parzen Estimator. Instead of guessing blindly, it learns. After a short warm-up of random cycles, it sorts everything it has tried into a "good" pile (your best results so far) and a "bad" pile (everything else).
For the next cycle it asks a simple question: which untried settings look much more like the good pile than the bad pile? It samples there. Every result sharpens the two models, so the search keeps tightening around the settings that actually move your metric.
Because it spends cycles where the payoff is most likely, TPE finds strong settings with far fewer backtests than brute force or random, which matters when each cycle is slow.
Under the hood
TPE models the good and bad sets with kernel density estimates (a Parzen window per numeric parameter, Bernoulli with Laplace smoothing per boolean). It scores each candidate by the log-ratio of the good density over the bad density and proposes the strongest one.
The split between good and bad is the top quartile (gamma = 0.25). Each proposal draws 24 candidates from the good model and keeps the best. A short adaptive warm-up (about 10 random cycles, scaled to your budget) seeds the models before they take over.
This is the same family of sampler that production hyperparameter tools such as Optuna use. It treats your backtest as an expensive black box, which is exactly the right assumption for strategy optimization.
- Good / bad split
- Top 25%
- gamma = 0.25
- Candidates per cycle
- 24
- Warm-up
- ~10 random cycles
- adaptive to budget
When to use it
Reach for it when
- Most strategies, especially when each backtest cycle is slow
- Medium to large parameter spaces where exhaustive search is hopeless
- When your cycle budget is tight and every run has to count
Reach for something else when
- Tiny spaces of three or fewer parameters, where Brute Force just wins
- When you want a fully deterministic, repeatable plan (TPE samples)
Auto-selected: The default for new strategies, and auto-selected when 11 or more parameters are enabled.
Want to see optimization in action? Browse our real strategy backtests vs buy and hold on NVDA, TSLA, and AAPL.
New to this? Read how to run your first optimization or learn how to choose the right optimization method for your strategy.
Related methods
-
Bisection then TPE Refine
Runs the full Bisection search, then hands the remaining budget to TPE to refine around the peak.
Quality 5 of 5Speed 3 of 5O(N log N + K log K) How it works -
Simulated Annealing
Wanders widely at first, then settles toward an optimum as the acceptance temperature drops.
Quality 4 of 5Speed 3 of 5O(N) How it works -
Random
Picks a fresh independent parameter set every cycle. No memory, hard to beat as a baseline.
Quality 3 of 5Speed 5 of 5O(N) How it works