TITLE: Expectation of $TS_T$ where $T$ is the absorption time at $\{a,-a\}$ of a simple symmetric random walk $\{S_n\}$
QUESTION [5 upvotes]: I was trying to calculate the expectation of $T^2$ using some martingale and got that I needed the expectation of $TS_T$. Any idea?

REPLY [9 votes]: If $(S_n)$ is a simple symmetric random walk on the integers, then $S_n^3-3nS_n$ is a martingale. Applying the optional stopping theorem for martingales, we get 
$$ \mathbb{E}_x(S_T^3-3TS_T)=\mathbb{E}_x(S_0^3-0)=x^3.$$ Here $-a\leq x\leq a$ is the starting point of the random walk and $T$ is the hitting time of the boundary $\{-a,a\}$. 
Standard results tell us that 
$$\mathbb{P}_x(S_T=a)={a+x\over 2a}\quad\mbox{ and }\quad\mathbb{P}_x(S_T=-a)={a-x\over 2a}$$
so that $\mathbb{E}_x(S_T^3)=a^2 x$. It follows that $\mathbb{E}_x(T\ S_T)=(a^2x-x^3)/3$. 

To find $\mathbb{E}_x(T^2)$,  you could use the martingale $S_n^4-6nS_n^2+2n+3n^2$.

Update: The non-symmetric case.
Here is an infinite family of exponential martingales.
For any real $\theta$ you can check that $\exp(\theta S_n)/[m_X(\theta)]^n$
is a martingale. Here, $m_X$ is the moment generating function of 
the increment $X$. For a non-symmetric random walk this will be
$m_X(t)=q \exp(-\theta)+p \exp(\theta)$.
Starting with the exponential martingales, you can generate other
martingales by differentiating with respect to $\theta$, then setting
$\theta=0$. The first two martingales you get this way are 
$S_n-n\mu$ and $(S_n-n\mu)^2-n\sigma^2$ where $\mu,\sigma^2$ are 
the mean and variance of the increment $X$.
For more on this topic, take a look at Example M.1.3 (page 3) of 
Professor Glynn's notes on martingales.