Macro Regime Engine: Monte Carlo & Walk-Forward Results
Spent the last week rebuilding the MRE in Python & Javascript so I'd be able to run forward analysis and the results were nothing short of brilliant.
I had an egregious thought pop into my head last week on a muggy Monday night.
“What if TradingView goes offline, gets hacked or worse.. they change their PineScript implementation or the assets they offer and my MRE (Macro Regime Engine) is no longer viable.”
I’m always thinking about disaster recovery and more importantly.. having a stable fault tolerant foundation for my systems. Relying exclusively on TradingView for the MRE (the 8th rule is much easier to rebuild in another language given it’s just math) is a single point of failure.
After my head stopped spinning, I set another coffee pot brewing and began attempting to figure out how I could “port” the MRE to another foundation.
The first thought as it always is for me.. was “I wish I had a fucking Bloomberg terminal.”
And my second thought is always “there’s no way I’m paying $25,000 per year for that.. at least not yet.”
So I go to my trusty backup as I’ve always done: Python. Rebuilding the MRE in Python will not only let me have a ‘backup’ but it would allow me to do some forward-testing analysis which I have yet to do on the MRE.
Off to Python We Go
I began standalone Python replication of the Macro Regime Engine.. the goal being platform independence from TradingView so the system survives regardless of what happens to any single vendor.
After spending two nights comparing price data from TradingView versus Yahoo Finance and a plethora of other sources, I finally got something that matched TV’s implementation of the MRE close enough to where I was happy with it.
Once the core logic was locked in, the obvious next question was: how robust is this thing, really? Not just on the backtest, but under stress. So I ran it through a full Monte Carlo simulation and walk-forward analysis. Here’s what came back.
The base case over ~20 years of SPX data produces 37 trades, an 8.5% CAGR with a 0.81 Sharpe, max drawdown of -17.9%, and a 73% win rate.
Solid; it doesn’t match TV’s MRE 1 for 1 but it gets close enough (minus the drawdown which I wasn’t happy with but it left room for improvement).
Backtests are backtests.. everyone’s got a strategy that looks good in hindsight. The question is whether the edge holds up when you start shaking the tree.
Monte Carlo Analysis
For the Monte Carlo jitter test, I ran 3,000 simulations randomizing every entry and exit date by ±2 trading days. This simulates real-world execution slippage, you’re not always going to catch the exact bar the regime flips.
The result: 100% of simulations were profitable, 98.3% cleared an 8% CAGR, and the median profit factor was 9.48.
The 5th-to-95th percentile CAGR range was 8.2% to 9.6%: extremely tight.
The strategy simply does not care if you’re a day or two late on execution.
That’s the hallmark of a signal that’s capturing a real macro regime shift, not some fragile micro-timing edge.
I also ran 3,000 bootstrap simulations resampling actual trade returns with replacement.. 100% profitable, 91.2% above a 5% CAGR, median 8.3%.
Walk Forward Analysis
The walk-forward is where it gets interesting.
I used an expanding window: 5-year train, 2-year test, 1-year step, giving 15 out-of-sample folds spanning 2011 through early 2026. 14 out of 15 folds were profitable out-of-sample.
The one losing fold (2021-2023) posted a -0.9% CAGR.. basically flat during a period where the macro regime was genuinely ambiguous post-COVID.
Mean out-of-sample CAGR was 8.9% with a 0.90 Sharpe and -8.9% average max drawdown.
Here’s the kicker: the out-of-sample Sharpe was actually higher than the in-sample Sharpe (0.90 vs 0.83). That’s an 8% improvement out of sample, the opposite of what you see with curve-fitted garbage.
Conclusion? Zero overfitting signal.
Takeaways
The bottom line: the MRE isn’t a backtest artifact.
It’s a regime classification system that identifies persistent macro environments.. Goldilocks, Reflation, Inflation, Deflation, and positions accordingly.
The edge comes from the macro regime itself being slow-moving and persistent, not from optimized parameters or cherry-picked lookback windows. When you jitter the timing, the returns barely move.
When you walk it forward through two decades of wildly different markets: GFC, QE infinity, COVID, the 2022 rate shock, the 2024-25 AI boom, it keeps working.
That’s the whole point. You don’t need to predict the future.
You just need to correctly identify the present.
Extras
I’ve been floating the idea of potentially releasing this on DurdenBTC.com as part of the members area. I’ve already done the work to port it from Python to Javascript but I need to stress test it. I don’t want people following this as a signal, its merely a “backup” to the actual MRE on TradingView.
However it would be good for a confluence and could be interesting for folks to track if they wish. I’m still mulling this idea around in my head.
Anyway, that’s all for today.
Thanks for reading!
— Durden out.
✊🧼






