Automated Trading Strategy #96: Smart Position Sizing With ML
“Edge isn’t just where you trade; it’s when you trade the most.”— Linda Raschke
Important: There is no guarantee that ATS strategies will have the same performance in the future. I use backtests and forward tests to compare historical strategy performance. Backtests are based on historical data, not real-time data so the results shared are hypothetical, not real. Forward tests are based on live data, however, they use a simulated account. Any success I have with live trading is untypical. Trading futures is extremely risky. You should only use risk capital to fund live futures accounts and if you do trade live, be prepared to lose your entire account. There are no guarantees that any performance you see here will continue in the future. I recommend using ATS strategies in simulated trading until you/we find the holy grail of trade strategy. This is strictly for learning purposes.
We’re on the hunt for the holy grail of automated trading strategy. If you have any questions, start with the FAQs and if you still have questions, feel free to reach out to me (Celan) directly at AutomatedTradingStrategies@protonmail.com.
“Markets are rarely random, they are just good at hiding their patterns.”
— Jim Simons (2024 Bloomberg New Economy Forum)
As we tap into the realm of machine learning to discover hidden market patterns, we are entering a new part of the forest. It may be uncomfortable at times, but the rewards are great.
Let’s go!
From Finding the Watering Holes to Building an Oasis
Strategy 96 is a continuation from Strategy 95. It is one of my favorite strategies because we use ML to find non-linear patterns that we always knew were there.
The goal of Strategy 95 was to see if we could improve upon a simple MACD cross strategy using market regimes identified via clustering. We found some really nice watering holes. Now it’s time to see how long they persist.
Recap: What Strategy 95 Taught Us
Clustering is great, but not a crystal-ball, it’s a map showing which local terrains (regimes) have historically been lush.
We can create clusters based on any metric. Our focus is on high-win-rate clusters (Steady Oasis, Mr Precision, Dynamic Optimist). These clusters repeat across bar sizes and instruments.
Simply flipping, throttling, or sitting out the MACD in unfavorable clusters already improves the profit factor vs. vanilla MACD.
We Know Where—Now Let’s Ask How Long: Why Persistence Matters (and how to measure it)
“Edge isn’t just where you trade; it’s when you trade the most.”
— Linda Raschke (Traders’ Chat, May 2025)
Strategy 96 is our first well-digging exercise.
Identify a lush spot (cluster).
Measure how long it persists.
Size the trade accordingly.
Clusters say “this bar is green.” They don’t say “green will probably last another seven bars.” In 96, this is the question we want to answer. We are looking for the probability that green will ‘persist’.
It’s important to distinguish between accuracy (win rate) and persistence. Just because a regime is persistent does not mean that it has a high win rate or vice versa. A regime may produce a high win rate for only one bar. Likewise, a regime can be persistent, lasting 7 or 8 bars, but have a low win rate. Best case scenario is a highly profitable regime with a high degree of persistence. That’s what we’re looking for in Strategy 96.
Strategy 96 uses six market regimes. The six regimes come from a k-means clustering run (k = 6) on the standardized 30-minute-bar feature matrix. They are as follows:
I then measured the performance of each regime by profit factor. An extremely good argument can be made for using win rate given the nature of the command (MACD cross up) and I plan on adding a version of that strategy to the Incubator. Meanwhile, here’s the impact of toggling each regime by profit-factor.
Regimes 3 and 4 are the heavy lifters—turning them on boosts profit factor an order of magnitude compared with runs where they’re off. Regimes 0-2 act like noise filters—keeping them off correlates with much higher PF.
So we’re going to enable Regimes 3 and 4 because they have the highest profit factor.
Now let’s measure the persistence of Regimes 3 and 4.
To measure persistence, I quantified how long Regimes 3 & 4 normally last (e.g., R3 holds 2 bars ≈ 100 %, 3 bars ≈ 78 %), and then converted those odds into rules. Here’s a transition matrix for Regimes 3 and 4:
R3 is sticky (85% hold rate); when it flips, most often to R2 (8%). R4 is less stable—60% chance to stay, 25% chance it degrades into choppy R2.
How can we use this information to size?
So the dynamic sizing is as follows:
BaseQty input sets your normal size.
Regime 3 ups size by +1 after two bars and +2 after three.
Regime 4 ups size by +1 after two bars.
All other regimes revert to BaseQty.