TITLE: Expected number of tosses until 3 heads in a row - via Martingale method
QUESTION [8 upvotes]: (Quant job interviews - questions and  answers - Question 3.8)

For a fair coin, what is the expected number of tosses to get 3 heads in a row

The answer is stated as :

We gamble in such a way that we make money on heads but such that if we get a T on toss $n$, our position is $-n$.

We therefore gamble one unit on the first toss and on each toss after a $T$. 

After one head, we gamble three. This guarantees that if we get a $T$ next then we go to $-n$. 

After two heads we are therefore up 4, and so we gamble 7  to get us to $-n$ again. our gambling winnings is a martingale since we are making finite trades in a martingale (any bounded trading strategy in a martingale is a martingale).

After three heads our position is $11 - (n-3)=14-n$. the time taken to get three heads is a stopping time with finite expectation so if we stop at it we still have a martingale (Optional sampling theorem) thus $\mathbb E (14 -n) = 0 $ and we are done.

I realise there are a few answers to this already, however i am not sure the explanation above, which uses martingale theory, is entirely clear.
The author states that  any bounded trading strategy in a martingale is a martingale  but what is the underlying martingale here ?
Also I don't understand the underlying  motivation for gambling the way described, please could someone put it in more mathematical terms so i can understand the reason for the sizes of the bets ?

REPLY [3 votes]: I believe that the strategy is that: 
consider the payoff of the $i_{th}$ toss
(1) If $i == 1$ or $X_{i-1} = Tail$  , you bet 1 unit on Head. Which means that $Payoff_i(X_i=Tail) = -1$ $Payoff_i(X_i=Head) = 1$;
(2) If $X_{i-1} = Head$  , you bet 3 unit on Head. Which means that $Payoff_i(X_i=Tail) = -3$ $Payoff_i(X_i=Head) = 3$;
(3) If $X_{i-2} = Head$ and $X_{i-1} = Head$  , you bet 7 unit on Head. Which means that $Payoff_i(X_i=Tail) = -7$ $Payoff_i(X_i=Head) = 7$;
(4) stop tossing when you get HHH serial.
Conclusions about this strategy:
(1) If you get a Tail at $i_{th}$ toss, your total payoff is $-n$(you could test this conclusion for arbitrage simple series);
(2)For every toss, your expected payoff is zero. Your total payoff is a martingale.
$$ \text{
**any bounded trading strategy in a martingale is a martingale** 
}
$$
I think that the first "martingale" in this quote is the total payoff $M_t = \sum_{s=0}^tpayoff_s$.
The trading strategy descripted above is also a maringale.
When this strategy stop, denote $n$ as the strategy stopping time. The expected payoff should be zero.which is 
$E[-(n-4)+1+3+7]=14-E[n]=0$. $E[n]=14$.