Anti-martingale strategy: pyramiding winners, explained with code

The anti-martingale is the martingale flipped on its head — and it is the version professional trend-followers actually use. Instead of doubling down after losses, you increase size after wins and cut size after losses. This aligns risk with what is working: you bet bigger when the strategy is winning and smaller when it is struggling, so winning streaks compound and losing streaks shrink your exposure automatically. This guide explains how anti-martingale works, the pyramiding rules that make it practical, the trade-offs, and a code example.

On this page
  1. What anti-martingale is
  2. Why it survives
  3. Pyramiding into winners
  4. Anti-martingale in code
  5. The trade-offs
  6. Where it fits
  7. FAQ

What the anti-martingale strategy is

The anti-martingale — also called the reverse martingale — increases position size after a win and decreases it after a loss. It is the exact inverse of the martingale. The logic: press your advantage when you are winning, and protect capital when you are not, so the exponential growth works for you on streaks rather than against you.

Why it survives where martingale ruins

With anti-martingale, a losing streak shrinks your size toward the minimum — you bleed slowly and survive to trade another day. A winning streak grows your size, compounding gains. The risk profile is the mirror image of martingale: many small losses and occasional large wins, which is the natural shape of a trend-following edge.

losses: size shrinks wins: size grows
Anti-martingale shrinks exposure during losing streaks and grows it during winning streaks — the opposite of martingale.

Pyramiding into winners

The practical form is pyramiding: add to a winning position as it moves in your favour, each added tranche smaller than the last, with the stop trailed up so the combined position never risks more than your fixed budget. Use a trailing stop to lock in gains as you scale, and size each tranche from the position calculator.

Anti-martingale in code

python · anti_martingale.pybase = 100
size = base
for trade in stream:
    if trade.win:
        balance += size * trade.tp
        size = min(size * 1.5, base * 4)   # grow, but cap it
    else:
        balance -= size
        size = base                          # reset DOWN after a loss

The trade-offs

Drawdown shape, not a free lunch

Anti-martingale wins big on trends but suffers many small losses in choppy markets — a frustrating string of paper cuts. It also gives back open profit when a winning trade reverses before your trailing stop. It is survivable and edge-friendly, but it needs a real directional signal underneath; on noise it just bleeds the base size repeatedly.

Where it fits

Anti-martingale shines on trend-following and breakout systems where wins are large and infrequent. Pair it with a trend filter, cap the maximum pyramided size, and validate the whole thing — including a chop period — on the backtester.

Not financial advice. This content is educational. Automated and algorithmic trading carries a real risk of financial loss. Never trade money you cannot afford to lose. Review the SEC investor.gov and CFTC resources before trading.

Frequently asked questions

What is the anti-martingale strategy?

The anti-martingale, or reverse martingale, increases position size after a win and decreases it after a loss — the exact opposite of martingale. It presses your advantage during winning streaks and protects capital during losing streaks, so exponential sizing works for you rather than against you. It is the sizing logic behind most professional trend-following systems.

Is anti-martingale safer than martingale?

Far safer. Under anti-martingale a losing streak shrinks your position toward the minimum, so you bleed slowly and survive, while martingale grows size into a loss until the account blows up. Anti-martingale produces many small losses and occasional large wins — a survivable profile — whereas martingale hides a near-certain catastrophic loss in the tail.

What is pyramiding in trading?

Pyramiding is the practical form of anti-martingale: adding to a winning position as it moves in your favour, with each added tranche smaller than the last and the stop trailed up so total risk never exceeds your fixed budget. It lets a strong trend compound your position while a reversal only gives back a controlled amount.

What is the downside of anti-martingale?

It performs poorly in choppy, directionless markets, producing a frustrating string of small losses, and it gives back open profit when a winner reverses before the trailing stop triggers. It needs a genuine directional edge underneath — on pure noise it simply bleeds the base size repeatedly without the big trend wins that justify it.

MB

Mustafa Bilgic

Algorithmic trading practitioner · Founder, AITradingBot.us

Mustafa builds and backtests automated trading systems and writes about them without the hype. Every tool on this site is free and runs entirely in your browser.