← Blog
· Last updated 2026-05-10

Genetic Algorithms for Crypto Trading: A No-Bullshit Primer

genetic-algorithmtrading-theoryhow-it-worksai-trading

Most products marketed as "AI trading bots" are not doing anything most people would recognize as AI. They are a fixed set of if-then rules — RSI crosses above 70, sell; price breaks 20-period high, buy — with parameters chosen by whoever wrote the code. Those parameters are usually picked by running the rules on historical data until the backtest looks good.

That is not AI. That is curve fitting.

Here is what a genetic algorithm actually does, where it breaks, and what it takes to run one that survives contact with real markets.

The Core Idea

A genetic algorithm borrows the logic of natural selection. You start with a population of candidate solutions (trading strategies). You evaluate their fitness (how well they trade). The fittest ones survive and reproduce. Reproduction mixes genes from two parents (crossover) and introduces random variation (mutation). You repeat this over many generations. Strategies that trade well continue to exist. Strategies that trade badly die.

The key insight is that you are searching a high-dimensional parameter space without knowing which parameters matter. In Darwin Lab, each strategy has roughly 30 parameters:

The space of possible combinations is enormous. A human sitting down to test combinations by hand would take years to cover even a fraction of it. The GA explores it automatically, guided by what actually works.

Fitness: The Part That Decides Everything

Fitness function design is where most GA trading implementations fail. If you optimize for win rate, you get a strategy that takes tiny profits and holds losses. If you optimize for total return, you get a strategy that occasionally makes one giant trade and nothing else.

Darwin Lab uses a composite fitness score:

The weights matter. If you drop the drawdown penalty, the GA reliably finds strategies that produce great returns until a single losing streak wipes the account. The current weights are the result of observing what happens when you shift them.

There are also hard disqualifications: a strategy must complete at least 30 trades in backtesting, or it receives a fitness score of -999. A strategy that overtrades (more than 200 signals per test window) receives a penalty. A strategy that is barely above coin-flip accuracy receives a penalty. These exist because the GA will happily find strategies that look good by exploiting gaps in the fitness function if you let it.

The Part That Makes Backtests Lie

Running a GA and looking at the best backtest result tells you almost nothing about how the strategy will perform live. The GA found parameters that worked on your specific historical data window. It did not find a universal truth.

The standard fix is out-of-sample testing: train on one window, test on a separate window you never touched. Darwin Lab uses 5-fold walk-forward validation. The full dataset is split into 5 consecutive time windows. The strategy must be profitable in at least 3 of the 5 folds. If it only works in 2 folds or fewer, it fails validation regardless of the aggregate backtest return.

This alone is not enough. A strategy can pass walk-forward validation on historical data and still decay the moment it goes live. The reasons are:

  1. Microstructure changes. Spread behavior, liquidity distribution, and order flow patterns shift over time. A pattern that was persistent in 2024 data may not be persistent now.
  2. Regime changes. A strategy tuned for a trending market will underperform in a ranging market. Most backtests cover multiple regimes without accounting for this.
  3. Overfitting on regime transitions. If your backtest window happens to contain a regime transition, the GA will often find parameters that "predict" the transition — a coincidence that will not repeat.

What Darwin Lab Does Differently

Forward-only promotion. No strategy trades real capital based on backtest numbers. After a strategy survives GA evolution and walk-forward validation, it enters a paper arena that runs every 2 minutes on real-time prices. Only forward arena stats determine whether a strategy promotes to the live roster. The promotion threshold is 15 arena trades, win rate above 25%, positive PnL, and profit factor above 1.2.

Regime specialization. The GA runs in four modes simultaneously: generalist (30 pairs, 60-day window), regime specialist (optimized for specific market regimes), liquid (30 most liquid pairs, 90-day window), and pair specialist (single-pair optimization). The executor knows which regime is active and weights signals from regime-matched specialists higher.

Regime detection. Current regime (weak_bull, strong_bull, range, weak_bear, strong_bear, crash) is computed daily from a classifier trained on BTC/ETH price structure, volatility, and trend metrics. Position sizing scales with regime: 1.20x in strong bull, 0.65x in strong bear, 0.40x in crash.

Killed DNA archive. When a strategy is killed (usually for negative live PnL or win rate decay below 20% over 50 trades), its genetic parameters are saved with the market regime it traded in. A resurrection scanner runs hourly and checks whether any killed strategy's native regime matches the current regime. If it does, and if the strategy had positive PnL in its native regime, it gets a second evaluation window in the paper arena.

Confidence gating. Before any signal hits Binance, an XGBoost model evaluates 48 features including time-of-day effects, regime alignment, indicator consensus strength, and the champion's recent forward performance trend. Signals below 45% confidence are blocked. The model is retrained weekly on actual live trade outcomes.

What This Cannot Do

A genetic algorithm finds patterns. It does not understand markets. It has no model of why prices move — it only knows whether certain input configurations have historically been followed by profitable price moves on specific pairs, in specific timeframes, under specific volatility conditions.

When market structure changes in a way that is discontinuous with the training data — a regulatory event, a major exchange failure, a sudden change in retail trader behavior — the GA's patterns can stop working before the system has enough data to detect the drift.

This is why the live configuration keeps position sizes small relative to account equity (6% risk per trade), caps leverage at 5x, and runs a loss shield that force-closes positions losing more than 8% of account equity.

The goal is not to eliminate losing periods. Losing periods are certain. The goal is to make sure no single losing period is terminal.

Full architecture detail is at /how-it-works. Live performance is at /track-record.


Risk disclaimer: Algorithmic trading involves substantial risk of loss. Full disclaimer.

Risk disclaimer: Trading futures involves substantial risk of loss. Past performance is not indicative of future results. Full disclaimer →

← Back to Blog