Skip to content
DiceSim

Martingale · 49.5% chance

Martingale dice bot script (Lua)

This script bets 49.5% for a 2.00x payout and doubles the stake after every loss. The first win after a losing run pays back the losses of that run plus one base bet, and the next bet drops back to the base bet.

A long enough losing run makes the next doubled bet bigger than the balance. With the defaults on a 0.01 balance that happens after 13 losses in a row.

The script

Lua 5.4 with DiceBot-style globals. The top level runs once to set chance and the first nextbet, then dobet() runs after every roll. Every global is described in the Lua reference.

luabasic-martingale.lua
-- Basic Martingale @ 49.5%
-- Payout 2.00x at 1% house edge. Double the bet after every loss, reset after a win.
-- It is the textbook example of streak risk: 10 losses in a row cost
-- 1023x your base bet. Use the calculator panel to size basebet for your bankroll.

chance  = 49.5
bethigh = false

basebet = params.basebet or balance / 10000   -- 0.01% of bankroll
nextbet = basebet

local multiplier = params.multiplier or 2.0   -- bet multiplier after a loss

function dobet()
  if win then
    nextbet = basebet
  else
    nextbet = previousbet * multiplier
  end
end

How it works

  1. chance = 49.5 and bethigh = false make every bet win on a roll below 49.5. At a 1% house edge that pays 2.00x.
  2. basebet is params.basebet when you pass one, otherwise balance / 10000, which is 0.01% of the balance at the start of the run. nextbet = basebet makes the first bet the base bet.
  3. multiplier is params.multiplier or 2.0. It is a local set once, before the first roll.
  4. dobet() runs after every roll. After a win it sets nextbet back to basebet. After a loss it sets nextbet = previousbet * multiplier, so a losing run bets 1, 2, 4, 8, 16 base bets and so on.
  5. There is no stop rule. The run ends when it reaches the number of rolls you set, when you stop it, or when nextbet is larger than balance.

Risk at a glance

Settings: 49.5% chance, 1% house edge, starting balance 0.01 (the template default, BTC in the simulator), base bet 0.000001 (balance / 10000).

Payout2.00x(100 - 1) / 49.5
Losses in a row to empty it13Those bets total 0.008191; the next one is more than what is left.
Chance of that streak1 in 7,1980.014% that 13 given rolls all lose
Expected rolls before it14,539Average wait for the first such streak
Chance within 10,000 rolls49.7%Chance the streak shows up at least once

Martingale is the case the dice calculator models directly: the bet doubles after a loss and resets after a win, so one losing streak is the only way the run ends.

Cost of a straight losing run from a fresh start
Losses in a rowChance of the streakResult from a fresh start
101 in 927 (0.108%)Lost 0.001023 (10.2%), next bet 0.001024
131 in 7,198 (0.014%)Lost 0.008191 (81.9%). The next bet, 0.008192, is more than the 0.001809 left
151 in 28,225 (0.0035%)Out of money after 13 losses
201 in 859,355 (0.00012%)Out of money after 13 losses

Theoretical figures for a fresh start, not a simulation. The chance of N losses in a row is qN with q = 1 - chance / 100, and the expected rolls before such a streak is (1 - qᴺ) / ((1 - q) × qᴺ). These are the same formulas the dice calculator uses. The 10,000-roll figure is 1 - e-10,000 / expected rolls, the chance that the streak shows up at least once. None of this changes the expected result: at a 1% house edge the average loss is 1% of the total wagered, whatever the progression.

Tuning it

Each setting below is read as params.name or default, so the script runs with the default until something passes a value in.

Parameters read by the Martingale script
ParamDefaultWhat changing it does
params.basebetbalance / 10000Size of the first bet. With a multiplier of 2, halving it lets the balance cover one more loss in a row, because each doubled bet costs as much as all the bets before it plus one base bet.
params.multiplier2.0Growth per loss. At a 2.00x payout, 2.0 is the smallest value where one win covers the losing run at any length. Lower values grow the bet more slowly, but a win after several losses no longer pays them back.

FAQ

Does the martingale strategy make money on dice in the long run?

No. At a 1% house edge every bet loses 1% of its size on average, and doubling the stake does not change that. Martingale turns many small wins into rare large losses. Over enough rolls the expected result is a loss of about 1% of everything you wagered.

How many losses in a row can a 0.01 balance survive with this script?

With the default base bet of 0.000001, 13. Those 13 bets add up to 0.008191. The next bet would be 0.008192, more than the 0.001809 left, so the run ends there.

How often does that streak happen?

At 49.5% the chance that 13 given rolls are all losses is 1 in 7,198. On average such a streak shows up once every 14,539 rolls, which gives about a 49.7% chance of hitting it within 10,000 rolls.

Can I run this script in DiceBot or another Lua dice bot?

The script uses the global names from Seuntjie's DiceBot (chance, bethigh, nextbet, previousbet, win, dobet()). The params table only exists in DiceSim, so replace each params.name or value with the value before you paste it into another bot. DiceSim itself never places bets on a casino.

Other scripts

Delayed escalation

Bets 3.35% for a 29.55x payout. Flat bets through 50 losses, then 4% more per loss.

Chance
3.35%
Type
Dynamic scaling

Paroli 3-step

Doubles after a win, banks the profit after 3 wins in a row, resets on any loss.

Chance
49.5%
Type
Paroli

Dynamic recovery

Sizes each bet so one win recovers the drawdown plus one base bet, capped at 10% of balance.

Chance
33%
Type
Recovery

D'Alembert

Adds one unit after a loss and removes one after a win, never going below the base bet.

Chance
49.5%
Type
D'Alembert

Labouchere

Bets the first plus the last number of a list. Wins cross numbers off, losses add one.

Chance
49.5%
Type
Labouchere

Fibonacci

Bets follow the Fibonacci sequence: one step up after a loss, two steps back after a win.

Chance
49.5%
Type
Fibonacci

Oscar's Grind

Plays in cycles that aim for +1 unit: same bet after a loss, one unit more after a win.

Chance
49.5%
Type
Oscar's Grind

1-3-2-6

Bets 1, 3, 2 and 6 units on consecutive wins. Any loss, or the 4th win, resets to 1.

Chance
49.5%
Type
Positive progression

Flat betting

Same bet on every roll, with a stop loss and a take profit at 10% of the starting balance.

Chance
49.5%
Type
Flat betting

Martingale + vault

Martingale that moves half of every 1% profit step to the vault with vault().

Chance
49.5%
Type
Martingale