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.
-- 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
chance = 49.5andbethigh = falsemake every bet win on a roll below 49.5. At a 1% house edge that pays 2.00x.basebetisparams.basebetwhen you pass one, otherwisebalance / 10000, which is 0.01% of the balance at the start of the run.nextbet = basebetmakes the first bet the base bet.multiplierisparams.multiplieror 2.0. It is alocalset once, before the first roll.dobet()runs after every roll. After a win it setsnextbetback tobasebet. After a loss it setsnextbet = previousbet * multiplier, so a losing run bets 1, 2, 4, 8, 16 base bets and so on.- There is no stop rule. The run ends when it reaches the number of rolls you set, when you stop it, or when
nextbetis larger thanbalance.
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).
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.
| Losses in a row | Chance of the streak | Result from a fresh start |
|---|---|---|
| 10 | 1 in 927 (0.108%) | Lost 0.001023 (10.2%), next bet 0.001024 |
| 13 | 1 in 7,198 (0.014%) | Lost 0.008191 (81.9%). The next bet, 0.008192, is more than the 0.001809 left |
| 15 | 1 in 28,225 (0.0035%) | Out of money after 13 losses |
| 20 | 1 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.
| Param | Default | What changing it does |
|---|---|---|
| params.basebet | balance / 10000 | Size 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.multiplier | 2.0 | Growth 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