The Infinite Monkey Problem in Trading Strategies
You’ve likely encountered the famous thought experiment: Give an infinite number of monkeys typewriters and infinite time, and one will eventually produce Shakespeare’s Hamlet word for word.
The idea comes from probability theory. If something has a nonzero chance of happening, then with enough attempts, it should occur eventually.
A standard typewriter has about 50 keys (letters, punctuation, space). Hamlet runs roughly 130,000 characters long (including spaces and punctuation). The odds of typing it perfectly on the first try?
1 in 50¹³⁰⁰⁰⁰.
That number is so huge it’s beyond human comprehension. How beyond?
Well, the number has 220,867 digits.
For context, the estimated number of atoms in the observable universe has a mere 10⁸⁰ atoms, a tiny fraction compared to the number of possible key combinations.
Even if a monkey typed at 5 keystrokes per second, continuously for the age of the universe (about 13.8 billion years), it’s still improbable that they will write shakespeare.
Real World Tests
In 2003, University of Plymouth researchers put a typewriter in a monkey enclosure. The result? The monkeys bashed it randomly, typed mostly the letter “S,” and eventually urinated on it.
Computer simulations fare slightly better. One program ran 2,737 trillion keystrokes, yet failed to produce even a single complete page from Shakespeare.
The longest correct sequence? 24 characters.
The Power of Infinite
But, what if time were truly infinite? Could it happen then?
Yes.
If a monkey truly had infinite time, then eventually, every possible sequence would occur.
Monkeys in Backtests
The infinite monkey theorem demonstrates how randomness can work in markets. Given sufficient attempts, some backtests will eventually provide impressive outcomes purely by chance, even though the backtest has no predictive power.
This connects directly to a major problem in backtesting. The risk of discovering “successful” trading strategies that are just the result of random chance.
Think of historical stock prices as Hamlet. Your trading strategy is like a monkey typing, it generates a sequence of buy/sell decisions. Most strategies are garbage (most monkeys type gibberish), but if you test enough variations, you’ll find some that match the historical data beautifully.
And when you’re testing thousands of strategies against millions of data points, you’re guaranteed to find amazing “winners” that are statistical flukes.
The more tests you run, the higher the chance of finding a “winner” by accident, just as more monkeys increase the odds of Shakespeare matches.
Simulation Exercise
To make this concrete, consider a simple simulation mimicking 20 years of S&P 500-like data.
Buy-and-hold delivered ~10% annualized.
You then test 10,000 purely random strategies, where each day the strategy randomly flips around independently of the data. No intelligence behind it whatsoever.
Then you get the following results:
The best random strategy gave you ~20% annualized returns, more than double the buy-and-hold!
The top 100 random strategies gave you around ~8% annualized. Still respectable.
The average random strategy gave you -3% (most lose money, as expected with no edge).
If you tested those 10,000 random strategies and picked the top winner, you’d genuinely believe you’d found a strategy that works. In reality, you just found a monkey that accidentally typed a few good sentences. Run that strategy on new data going forward and you’ll get the average return of -3%.
Monte Carlo
At CI Volatility, we understand there are many invalid strategies would beat the market over a specific time period by chance. One effective way to combat the “infinite monkeys” problem in backtesting is to incorporate Monte Carlo simulations.
What Are Monte Carlo Simulations?
Named after the famous Monte Carlo casino in Monaco (due to the element of chance, like roulette), the method relies on repeated random sampling to estimate outcomes that might be difficult to calculate with existing historical data.
It basically rewrites history over and over using random variables.
Monte Carlo is widely used in finance for portfolio optimization, and backtesting strategies.
Strengths:
Handles multi-variable problems well.
Provides full probability distributions (not just historical).
Flexible for “what-if” scenarios.
Limitations:
Computationally intensive
The results require good input (garbage in, garbage out).
Sensitivity Analysis
We complement this with sensitivity analysis, changing key parameters to pinpoint which inputs change performance most heavily. Robust strategies hold up even when you nudge the settings around a little bit. They're not hyper-sensitive to exact parameter values.
For example, if you are getting returns of 20%, and you change your RSI from 45 to 46, your returns shouldn’t go from 20% to 5%.
Invalid strategies fall apart at the slightest change which is a dead giveaway that they were just lucky.
By combining these techniques, we ensure our volatility-focused strategies are sound.





The simulation showing 10k random strategies with the best one hitting 20% is actually a perfect illustration of survivorship bias in action. I think the sensitivity analysis point is underrated too, becasue changing an RSI from 45 to 46 and watching returns colapse is literally just curve-fitting to noise. I've seen this happen with ML models where people train on teh same data they're testing and convince themselves they've found alpha. The real test is always out-of-sample performance but most retail traders never bother with walk-forward analysis.