When to stop doubling down? My question is similar to this one but very specificly different
When to stop in this coin toss game?
Imagine a game where you would start with $100.  Every time you can roll a die (d6), if it is 1-5 you double the winnings, but if it is a 6 you lose everything.
How would you calculate the ideal number of rolls to make?  Lets define ideal as "if preformed 1000 times, would have the highest average winning"
The question above is similar but the reward is linear.  With a linear reward it seems very clear, play until the winning odds become worse than the reward.  In this case though the reward always keeps up with the risk.  To me it seems like at any one moment the logical thing is to keep playing as the odds are in your favor.  It is obvious though that following that you are guaranteed a result of $0.
 A: As long as you keep "average winning" as your optimization criteria, the problem has no answer, per one game or per 1000 does not matter. If your strategy $S(n)$ is "roll $n$ times and keep the winnings (or keep 0 if loose during one of those rolls)", then the strategy $S(n+1)$ has better expected value.
The problem is that as n grows, the shape of winnings distribution becomes more and more skewed and $E(\cdot)$ as optimization criteria becomes less and less psychologically acceptable.
You may want to consider some soul searching and settle on different optimization criteria.
A: You seem bothered by the fact that the highest expectation comes with a high probability of getting zero.  Imagine a very simple game:  you are allowed to pay one dollar for a 1 in a million chance of winning a billion dollars.  The expectation is $\$1000$, so is much better than $\$1$, but almost all the time you wind up with nothing.  Even if you play $1000$ times, you will likely wind up with nothing.  We are also doing this in the mathematical sense, that we don't have to worry that your opponent will be able to pay off.  Before too many flips, they would have to give you more money than there is in the world.
A: Some economists have a resolution to the counterintuitive result that you should pursue a strategy which will almost certainly lead to no reward.  They suggest that you should maximize the average utility of your winnings.  The utility is a function of the amount won that, in the limit of high dollar amounts, typically has a logarithmic shape to its graph.  The reason for this is that, for most people, it is much more useful to win 1 million dollars starting with (close to) nothing than it is to win 1 million dollars if they already have a million dollars.  The first million dollars can change (and more debatably, improve) your life in very significant ways, while a second million dollars would not have the same impact.  And if someone already has 100 million dollars to their name, then gaining an additional 1 million dollars will not make much of a difference at all.
Empirically, it would seem that a typical person's utility function would be somewhat linear at low money amounts and become logarithmic at high money amounts.  You could choose various utility functions that model that kind of behavior and see what strategy each one suggests.  I think they will turn out to be of the form 'Keep placing bets until you've won an amount such that the likely (83%) gain of additional utility from winnings on the next play no longer outweighs the (17%) risk of losing the entire utility of the winnings so far'.
A: After first roll:
$P_1(\$200) = \frac{5}{6}$, $P_1(0) = \frac{1}{6}$. 
Expected value (average winning) $E_1[X] = P_1(\$200)\cdot 200 + P_1(0) \cdot 0 = \frac{5}{6}\cdot 200 = \frac{5}{3}\cdot 100$. 
After $2$ rolls:
$P_2(\$400) = \frac{5^2}{6^2}$, $P_2(0) = 1 - P_2(\$400) = \frac{6^2-5^2}{6^2}$.
$E_2[X] = P_2(\$400)\cdot 400 + P_2(0) \cdot 0 = \frac{5^2}{6^2}\cdot 400= \frac{5^2}{3^2}\cdot 100$. 
...
After $n$ rolls:
$P_n(\$100 \cdot 2^n) = \frac{5^n}{6^n}$, $P_n(0) = 1-\frac{5^n}{6^n} = \frac{6^n-5^n}{6^n}$.
$E_n[X] = P_n(\$100\cdot 2^n)\cdot 2^n \cdot 100 + P_n(0) \cdot 0 = \frac{5^n}{6^n}\cdot 2^n \cdot 100 = \frac{5^n}{3^n} \cdot 100$. 

Even if I see, that $E_n[X]$ increases with $n$, 
I'd stop on the last $n$,  when $P_n(\$100\cdot 2^n)>\frac{1}{2}$.
Because if $E_n(\$100\cdot 2^n)$ is very large, but probability to win is very small (when $n$ is large).
Let calculate it:
$P_1(\$200) = \frac{5}{6}>\frac{1}{2}$.
$P_2(\$400) = \frac{5^2}{6^2}=\frac{25}{36}>\frac{1}{2}$.
$P_3(\$800) = \frac{5^3}{6^3}=\frac{125}{216}>\frac{1}{2}$.
$P_3(\$1600) = \frac{5^4}{6^4}=\frac{625}{1296}<\frac{1}{2}$.
So, I'd stop on $3$rd step (if have fortune to get to $3$rd step) with $\$800$ or $0$.
Well, well, maybe on the $4$th step, because $P_4(\$3200) \lesssim \frac{1}{2}$.

But (!!!)
if you can repeat this game again, again (starting of $\$100$) $-$ then there are no doubts to play it endless!
A: As several people have already shown, there is no optimal value for stopping doubling down under these conditions.  And this is all correct: you are asking exactly the wrong question.  In the real world, gamblers the world over would kill for your conditions, and casinos would go broke offering them.
So what actually happens is that casinos strictly limit the ability to double down.  Specifically, a table game like blackjack with have a minimum and maximum bet, and these are not set arbitrarily.  They usually restrict the ability to double down to about 6-7 times.  If you are a "high roller", you might be able to convince management to up the maximum, but the casino will then try to up your minimum!  Casinos figured this out long ago, because long streaks do happen, and they would be costly if allowed.
A: The assumption that the game could go on forever, and therefore it is certain that the player will lose, is of course wrong: The game has to stop when the casino can't pay your current winnings. 
Now this game gives me a reasonable chance to gain enormous wealth; a "life changing" amount of wealth. There's a point where you wouldn't stop - $200, or $100,000, depending on your life situation, because you can handle not winning that amount. There's another point where you would stop because doubling your money doesn't make a difference - $20 million won't make me much happier than $10 million. Somewhere between these two is the best point to stop. (I'd probably stop at 6.5356 million dollars, and definitely at $13 million). 
