# Expectation of the following random variable related to random walk and stopping time

Assume that $S_n=\sum_{i=1}^n X_i$ where $X_i$ are iid r.v. with finite mean $E(X_1)=\mu$. Assume that $\tau$ is a stopping time with finite expectation. What's the expectation of $\tau S_\tau$? Is it $\mu E(\tau^2)$? How can we derive it?

I tried it in this way: $\mathbb{E}(\tau S_\tau)=\sum_{n=1}^\infty \mathbb{E}\tau S_\tau I(\tau=n)=\sum_{n=1}^\infty \mathbb{E}n S_n I(\tau=n)=\sum_{n=1}^\infty \mathbb{E}n \sum_{k=1}^n X_k I(\tau=n)$, then I got stuck with the term $\mathbb{E} X_i I(\tau=j)$ for $i<j$.

-

In general, $\mathbb E(\tau S_\tau)\ne\mu\cdot\mathbb E(\tau^2)$.
To see this in a simple case, assume that $\mathbb P(\tau\leqslant2)=1$, then $\mathbb E(\tau S_\tau)-\mu\cdot\mathbb E(\tau^2)=2\Delta$ where $\Delta=\mathbb E(X_1)\cdot\mathbb P(\tau=1)-\mathbb E(X_1;\tau=1)$. There is no reason why $\Delta$ should be zero since $X_1$ and $[\tau=1]$ are not independent in general.
Assume for example that $X_k=\pm1$ with equal probabilities and that $[\tau=1]=[X_1=1]$ and $[\tau=2]=[X_1=-1]$. Then $\tau$ is a stopping time, $\tau S_\tau=1$ on $[X_1=1]$ and $\tau S_\tau=-2+2X_2$ on $[X_1=-1]$, hence $\mathbb E(\tau S_\tau)=\frac12\cdot1+\frac12(-2+2\cdot0)=-\frac12$ while $\mu\cdot\mathbb E(\tau^2)=0$ since $\mu=0$.