Martingale · 49.5% chance
Martingale with profit vault dice bot script (Lua)
This martingale with profit vault script doubles the bet after each loss and resets it after a win, like the basic martingale script. Each time the session profit climbs another 1% of the starting balance, it moves 50% of that step to the vault with vault().
Vaulted money still counts as profit and can never be bet again. From a fresh start the losing streak that empties the balance is the same as for the basic script, 13 losses in a row at 49.5%. When it comes, it takes what is in the balance and leaves the vault alone.
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.
-- Martingale with a profit vault
-- Classic martingale: multiply the bet after a loss, reset after a win. Each time the
-- session profit climbs another `step`, move part of that step to the vault with
-- vault(). Vaulted funds count as profit but can never be bet, so a later bust only
-- takes what is still in the balance.
chance = 49.5
bethigh = false
basebet = params.basebet or balance / 10000
nextbet = basebet
local multiplier = params.multiplier or 2.0 -- bet multiplier after a loss
local step = params.step or balance / 100 -- profit gained between two vault deposits
local share = params.share or 0.5 -- fraction of each step moved to the vault
local nextLock = step
function dobet()
if win then
nextbet = basebet
else
nextbet = previousbet * multiplier
end
-- profit includes the vault, so vaulting does not move the next threshold
while step > 0 and profit >= nextLock do
vault(step * share)
nextLock = nextLock + step
end
end
How it works
chance = 49.5andbethigh = falsewin on a roll below 49.5, paying 2.00x.basebetisparams.basebetorbalance / 10000, which is 0.01% of the starting balance.multiplierisparams.multiplieror 2.0,stepisparams.steporbalance / 100(0.0001 on a 0.01 balance), andshareisparams.shareor 0.5.nextLockstarts atstep.dobet()first sets the bet:basebetafter a win,previousbet * multiplierafter a loss.- Then, while
profitis at or abovenextLock, it callsvault(step * share)and raisesnextLockby onestep.profitincludes vaulted funds, so a deposit does not lower it. - There is no stop rule. The run ends at your roll count, when you stop it, or when
nextbetis larger thanbalance. The vault stays part of the session profit in every case.
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).
From a fresh start this script bets exactly like the basic martingale, so the calculator's model applies and the numbers below match the basic martingale page. The vault changes what a bust costs: the balance is lost and the vault is kept. Each deposit also leaves less in the balance, so later runs of doubled bets have less to draw on than they would without the vault.
| 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. Halving it lets the balance cover one more loss in a row and halves the profit per winning run. |
| params.multiplier | 2.0 | Growth per loss. At 2.00x, 2.0 is the smallest value where one win pays back a losing run of any length. |
| params.step | balance / 100 | Profit between two vault deposits. A smaller step vaults sooner and more often, in smaller amounts. |
| params.share | 0.5 | Fraction of each step moved to the vault. 1 vaults the whole step and 0 turns the vault off. |
FAQ
Does the vault make martingale profitable?
No. The vault moves money the script has already won out of reach of later bets. Each bet still loses 1% of its size on average, and a run of 13 losses still empties a fresh 0.01 balance. What changes is how much a bust takes: the balance goes, the vaulted profit stays.
How often does the script vault?
At 2.00x each win of a martingale run adds exactly one base bet to the profit, because it pays back the losses of the run plus one base bet. With the defaults the step is 100 base bets, so a deposit of 0.00005 happens every 100 wins, as long as no bust comes first.
What does vault() do?
It moves an amount from balance to the vault, never more than the balance holds, and returns the amount moved. Vaulted funds are included in profit and vaulted, and no bet can use them.
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. It also calls vault(), so check that your bot provides it. DiceSim itself never places bets on a casino.
Other scripts
Martingale
Doubles the bet after each loss and goes back to the base bet after a win.
- Chance
- 49.5%
- Type
- Martingale
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