Here's the strategy:
1. Choose a game with a particular price multiplier to play. Let r = the price multiplier
2. Let total number of times you want to make a bet on this game = "bets".
3. Let maximum amount of coin willing to lose = "max"
4. p is probability of winning the game you're playing, q is the probability of losing the same game, q = 1 - p
5. Let the amount by which you multiply each bet after a loss be "m", m = 1/(1 - 1/r)
6. Let expected losses in a row be "n", n = -log(bets*p + 1)/log(q)
7. Let "init" be the ideal starting amount to gamble (in the absence of transaction fees and 0.5% return on loss = max/sum(m^(1:n))
Generally, transaction fees and return on loss have little effect on the strategy. However, if you would like to take them into account:
7. Let "init" be the starting amount to gamble when taking account fees and 0.5% return on loss,
init = (max - n * 0.0005)/(sum(m^(1:n))*(1 - sum(m^(1:(n-1)))/(sum(m^(1:n)))*0.005))
8. Calculate:
(1-(init*m^n*r - 0.0005)/(init*m^n*r))*100
This is the percentage of winnings lost to fees after an expected win (after n losses in a row). If this is too high, choose either higher max or lower number of bets and try again.
Warning: This strategy will only prevent you losing more than a maximum amount in the same order of magnitude as the one you selected. There's a lot of variance in the game, and sometimes you may lose much more - especially if p > 0.5 or your maximum is large. It works quite well with small maximum btc amounts.
For example, playing a the price multiplier = 8x game, wanting to bet 100 times and wanting to lose a maximum of 1 btc, not taking into account fees or returns on losses:
1. r = 8
2. bets = 100
3. max = 1 btc
4. p = 8000/65536, q = 1 - p
5. m = 1 / (1 - 1 / r)
6. n = round(-log (bets * p + 1) / log( q ))
7. init = max / sum( m ^ ( 1 : n ) )
8. % fee loss = (1-(init * m ^ n * r - 0.0005)/(init * m ^ n * r)) * 100
then
m = 1.142857
init = 0.009294345
% fee loss = 0.04653956%
As above, with fees and return on loss:
7. init = max / sum( m ^ ( 1 : n ) )
8. % fee loss = (1-(init * m ^ n * r - 0.0005)/(init * m ^ n * r)) * 100
then
m = 1.142857
init = 0.009241403
% fee loss = 0.04680618%
Below are some simulations of martingale betting on Satoshi Dice using the strategy outlined in this post. They show the usefulness of the strategy when you use a low max, as compared with the standard nightingale (start with 1btc, double each time you lose).
Courtesy of organofcorti but i wouldent mind some BTC for pointing you in the right direction
-->
https://bitcointalksearch.org/topic/satoshi-dice-how-to-last-longer-94481