Martingale is the oldest betting system there is: lose, double the stake, and the first win pays back everything. In short-expiry trading it comes up every week: "×2 or ×2.5?", "how many steps?", "same direction or flip it?". Probability theory answers it in one line: if each trade is independent of the previous one, no rule for changing the stake changes the expected result per dollar staked.
So why simulate it at all? Because the people who use martingale aren't really arguing with that line. Their claim is about the data: after a loss, the price on the same asset is more likely to turn. That's something you can check on candles. And a simulation of money is easy to get wrong in ways that look like an edge.
We had about 2.95 million one-minute candles: 101 synthetic "OTC" assets (quotes generated by the broker rather than taken from an exchange) and 21 regular currency pairs, recorded from a trading chart from July 24 to September 17, 2026 (with a three-week recording gap in August, more on that below). Below is how we turned them into 180 martingale setups, and the four places where the simulation could have lied to us.
The data: flat arrays, not objects
Three million { ts, open, high, low, close } objects work, but they're slow and heavy in Node. Each asset is stored as a few typed arrays instead:
/** One asset's minute series in flat arrays: we don't keep millions of bars as objects. */ interface Series { ts: Float64Array; open: Float64Array; close: Float64Array; } A trade is just three indexes: the bar where it opens, the bar where it closes, and the direction.
The ladder
The rules are the default ones of an auto-trader we work on: a signal on a closed minute opens the first trade with a stake of 1. A loss opens the next step immediately, on the same asset, in the same direction, with the stake times the multiplier. A win or a draw ends the ladder. After the last step the ladder is "busted" and the full loss is taken.
/** Outcome of one trade from bar `at` for `expiryBars` bars; null if the series has a hole. */ function tradeOutcome(s: Series, at: number, expiryBars: number, dir: Direction): Outcome | null { const exitBar = at + expiryBars; if (exitBar >= s.ts.length || s.ts[exitBar] !== s.ts[at] + expiryBars * 60_000) return null; const entry = s.close[at]; const exit = s.close[exitBar]; return exit === entry ? 'draw' : (dir === 'call') === (exit > entry) ? 'win' : 'loss'; } /** Outcomes of a ladder started at bar `at`: until the first non-loss, at most maxSteps + 1 trades. */ function ladderOutcomes(s: Series, at: number, expiryBars: number, dir: Direction, maxSteps: number): Outcome[] | null { const out: Outcome[] = []; for (let k = 0; k <= maxSteps; k++) { const o = tradeOutcome(s, at + k * expiryBars, expiryBars, dir); if (!o) return null; // the ladder ran into a hole: its result is unknown out.push(o); if (o !== 'loss') break; } return out; } Money is settled separately, from the outcomes, with the payout of that asset:
function settle(outcomes: Outcome[], payout: number, multiplier: number) { let profit = 0, turnover = 0, stake = 1; for (const o of outcomes) { turnover += stake; if (o === 'win') { profit += stake * payout; break; } if (o === 'draw') break; profit -= stake; stake *= multiplier; } return { profit, turnover }; } Keeping "what happened on the chart" and "what it cost" apart paid off later: the same outcomes were settled with ×1.5, ×2 and ×2.5 without walking the candles again.
Lie #1: holes in the data become wins
The recorder sometimes stopped: a restart, a lost connection, an asset that went offline. Once it was off for three weeks. The naive version of tradeOutcome takes the bar at + expiryBars by index. Across a hole that bar is hours or days later, and the trade gets settled against a price from another session.
That's bad for a single trade and worse for a ladder. A ladder that runs into a hole ends early. If "ended" is counted as "closed", every hole quietly removes a few of the long losing ladders, exactly the ones that decide the result. Hence two rules in the code above:
- the exit bar must be exactly
expiryBarsminutes after the entry bar, by timestamp, not by index; - a ladder that runs into a hole is dropped entirely, not counted as closed. There were only a few of them per several thousand ladders, but they are the wrong few to lose.
Lie #2: ladders that overlap
The natural way to count is "for every signal, play a ladder". But a real account with one trade at a time can't do that: while a ladder is alive, new signals are skipped, on every asset. Playing all of them counts the same losing streak several times from different starting points, and the money totals turn into fiction.
So ladders are played as a stream, in time order, with a single slot:
let freeAt = -Infinity; for (const e of signals) { // sorted by time if (e.ts < freeAt) continue; // the slot is busy: the account would miss this signal const s = seriesOf(e.series); const outcomes = ladderOutcomes(s, e.at, expiryBars, e.dir, maxSteps); if (!outcomes) continue; played.push({ ts: e.ts, series: e.series, outcomes }); freeAt = s.ts[e.at + outcomes.length * expiryBars]; // freed at the close of the last step } One detail matters: the slot frees on the closing bar, not after it. A trade closing and a new signal arrive on the same tick, and the real account takes that signal. With <= instead of < the stream would skip it.
The first number isn't money
Before any totals we looked at the win rate of each step separately. That's the whole question: does a trade placed after one, two, three losses win more often than the first one? One of the signals, OTC, 1-minute expiry, ×2.5, up to 3 steps:
- first trade: 50.1% (14,829 trades)
- step 1, after one loss: 50.8% (7,298)
- step 2, after two losses: 50.1% (3,540)
- step 3, after three losses: 50.8% (1,744)
The other signals look the same, a bit above or a bit below 50%. A second check: how often a ladder lost all four trades. Observed: 5.72%. Expected if every step lost as often as the first trade: 5.91%. The price doesn't "owe" a reversal.
Breakeven at the average OTC payout of 88.6% is 1 / (1 + 0.886) ≈ 53%. Nothing came close.
Lie #3: the half that wasn't a half
Every setup is judged on two halves of the data: picked on the first, checked on the second. With 180 setups some will look good on one half just by chance, so "positive on both halves" is the bar.
In an earlier study on the same archive we split by calendar: the middle date. It fell into that three-week recording gap, and the "second half" turned out to be 18 hours of data; some assets had no bars in it at all. Nothing crashed, the numbers just became noise with a confident face.
Now the boundary is the median timestamp over all bars of the measurement, so both halves have the same number of bars whatever the gaps are. A half with fewer than 300 settled trades isn't judged at all.
Lie #4: the money engine itself
This is the one we worried about most. The bot-like replay (one engine for all modes: loss-side ladders, win-side ladders, "flip the direction", "wait for the next signal", "a draw counts as a loss", stake caps) is a few hundred lines of state. An off-by-one in it would produce an edge or a loss that isn't in the data.
The test is a control market: for each asset, a random walk with the same timestamps, the same starting price, the same spread of one-minute returns and the same price step (rounding matters: it's what produces draws).
/** A fair random walk shaped like the segment: the next bar's direction depends on nothing. */ function randomWalkLike(segment: Candle[], rnd: () => number): Candle[] { const sigma = stdevOfLogReturns(segment); const scale = 10 ** decimalsOf(segment); // keep the asset's price step const round = (x: number) => Math.round(x * scale) / scale; const out: Candle[] = []; let prev = segment[0].open; for (const bar of segment) { const close = round(prev * Math.exp(sigma * gauss(rnd))); out.push({ timestamp: bar.timestamp, open: prev, close, /* high, low … */ }); prev = close; } return out; } On such a series, the theory gives a hard invariant: the result per dollar staked is the same for every mode, because the expectation is linear in the stake. With a 92% payout and a 50/50 coin that's 0.5 · 0.92 − 0.5 ≈ −4% per dollar, whatever the multiplier, the direction or the number of steps.
That's what we got: every mode on every signal landed between about −1.5% and −6%, around −4%. The spread is wider for modes with big stakes (a few busted 25-stake ladders weigh as much as a hundred normal trades), but no mode drifted systematically to one side. If one had, the engine would be counting money wrong, and none of the real-market numbers would mean anything.
One more cross-check came for free: two independent implementations of the default ladder (the chain model above and the bot-like replay) gave −3,969 and −4,017 stakes on the same signal, on slightly different cuts of the archive. Close enough to trust both.
What came out
All the combinations: same or opposite direction, recovery right away or on the next signal, a draw counted as a win or a loss, ×1.5 / ×2 / ×2.5, 1 to 3 steps, raising the stake after wins instead of losses, both at once. Times three signals, two expiries, OTC and regular pairs.
180 setups. Positive on both halves: 0. The best one lost 1.9 cents per dollar staked, on regular pairs.
The most useful picture is one signal, OTC, 1-minute expiry, $1 base stake, the whole period:
- flat stake: −$1,478, or −5.3 cents per dollar staked;
- ×2.5, up to 3 steps: −$4,017, or −4.8 cents per dollar staked.
Per dollar it's the same loss. Martingale just puts about three times more dollars through it.
Then the bank. We cut the stream into separate runs of 500 ladders, each with a fresh bank, and counted runs where the next step couldn't be paid for. With a bank of 100 stakes, ×2.5 ran out in 73% of runs and ×2 in 60%. With 250 stakes: 40% and 3%. A bigger bank moves the moment, not the average.
The win-side version (raise the stake after a win) was checked against a plain formula: a 50/50 coin with the same payout and the same session rules. OTC matched the coin.
What we'd tell ourselves before starting
- Measure the claim, not the strategy. "Martingale works" is really "a loss makes the next trade more likely to win". That's one table of win rates per step, and it's more convincing than any equity curve.
- Holes in the data are not neutral. They tend to cut off exactly the long events that decide the result. Check time, not index, and drop what you can't settle.
- Model the account, not the signals. One slot, one trade at a time, signals skipped while it's busy.
- Split by data, not by calendar.
- Give the engine a market where you know the answer. A random walk shaped like your data, plus an invariant that must hold on it. It catches bugs that unit tests on hand-made cases don't, because the bug is usually in the interaction of rules nobody thought to combine.
Our first post here was about the other half of the same codebase: drawing indicators with one codebase in a browser extension and on a website. Questions about the method are welcome in the comments.
This article was written with the help of AI: the measurements, the code and the decisions are ours, the AI helped to put them into words and to translate.