Determine $E\sum_0^\infty X_n1_{(T=n)}$ $X_T = \sum_0^\infty X_n 1_{(T=n)}$ where $T$ is a stopping time and $(X_n)$ is a martingale. Show that if $T$ is bounded then $EX_T = EX_0$: 
$T \leq N$, and then consider $X_T = X_{T\wedge N} = \sum_0^NX_n1_{(T = n)}$
We have, $$EX_T = E\sum_0^NX_n1_{(T = n)} = \sum_0^NE(X_n1_{(T=n)})$$
Now I am having troubles using the properties of martingales, usually we have that $E(X_n | \mathcal{F}_{n-1}) = X_{n-1}$ but I don't see how to use that property here as we're not conditioning on $(\mathcal{F}_n)$ yet. This is my first introduction to martingales so please if someone could explain how I could tackle this problem in detail 
edit: using how you defined $X_T$ I have:
$$E(X_T | \mathcal{F}_{n-1}) = E(X_0|\mathcal{F}_{n-1}) + \sum_1^NE((X_j - X_{j-1})1_{T\geq j})|\mathcal{F}_{n-1})$$ now as you said $\{T \geq j\} \in \mathcal{F_{j-1}}$  so $E(X_j - X_{j-1})1_{T\geq j}= 1_{(T\geq j)}( E(X_j|\mathcal{F}_{n-1}) - E(X_{j-1} | \mathcal{F}_{n-1}))$ but again I am stuck here
edit: is it right to say that: $E(X_0|\mathcal{F}_{n-1}) = X_0$ and $$E((X_j - X_{j-1})1_{T\geq j})= 1_{(T\geq j)}( E(X_j|\mathcal{F}_{n-1}) - E(X_{j-1} | \mathcal{F}_{n-1}))= 1_{(T\geq j)}(X_{j-1} - X_{j-1})?$$
another solution:
Could we not do it like this: If $T \leq N$ then $X_T = \sum_0^N X_n 1_{(T=n)}$ now if I take the expectation $$E(X_T | \mathcal{F}_0)= \sum_0^N E(X_n1_{(T=n)}|\mathcal{F}_0) = \sum_0^N 1_{(T=n)} E(X_n | \mathcal{F}_0)$$
now since $(X_n)$ is a martingale, we have $E(X_n | \mathcal{F}_0) = X_0$, which gives $E(X_T | \mathcal{F}_0) = X_0$ taking expectations again, and using the tower property we get $E(X_T) = EX_0$
 A: You have to rewrite $X_T$ in a clever way before doing the computations.
Hint:


*

*Show that
$$X_T = X_0 + \sum_{j=1}^N (X_j-X_{j-1}) 1_{\{T \geq j\}}.$$ Hence, $$\mathbb{E}(X_T)= \mathbb{E}(X_0) + \sum_{j=1}^N \mathbb{E}( (X_j-X_{j-1}) 1_{\{T \geq j\}}).$$

*Use the tower property to prove that $$\mathbb{E}(X_T) = \mathbb{E}(X_0) + \sum_{j=1}^N \mathbb{E} \bigg[ \mathbb{E}( (X_j-X_{j-1}) 1_{\{T \geq j\}} \mid \mathcal{F}_{j-1}) \bigg].$$

*Conclude from the fact that
$$\{T \geq j\} = \{T \leq j-1\}^c \in \mathcal{F}_{j-1}$$ and the martingale property that $$\mathbb{E}( (X_j-X_{j-1}) 1_{\{T \geq j\}} \mid \mathcal{F}_{j-1}) = 1_{\{T \geq j\}} \mathbb{E}(X_j-X_{j-1} \mid \mathcal{F}_{j-1}) = 0.$$



Alternative solution
Fix $j \leq N$, then it follows from that $\{T = j\} \in \mathcal{F}_j$ and the martingale property that
$$\mathbb{E}(X_N 1_{\{T=j\}} \mid \mathcal{F}_j) = 1_{\{T=j\}} \mathbb{E}(X_N \mid \mathcal{F}_j) = 1_{\{T=j\}} X_j \tag{1}$$
for $j=0,\ldots,N$. Hence, by the tower property,
$$\mathbb{E}(X_T) = \sum_{j=0}^N \mathbb{E}(X_j 1_{\{T=j\}}) \stackrel{(1)}{=} \sum_{j=0}^N \mathbb{E}(X_N 1_{\{T=j\}}).$$
Since $\bigcup_{j=0}^n \{T=j\} = \Omega$ and the sets $\{T=j\}$, $j=0,\ldots,N$, are pairwise disjoint, this implies
$$\mathbb{E}(X_T) = \mathbb{E}(X_N) \stackrel{\text{martingale}}{=} \mathbb{E}(X_0).$$

Remarks on your edited question

Is it right so say that [...] $$E((X_j - X_{j-1})1_{T\geq j})= 1_{(T\geq j)}( E(X_j|\mathcal{F}_{n-1}) - E(X_{j-1} | \mathcal{F}_{n-1}))= 1_{(T\geq j)}(X_{j-1} - X_{j-1})?$$

No, it isn't. Note that the martingale property states that $$\mathbb{E}(X_j \mid \mathcal{F}_{n-1}) = X_{n-1}$$ for all $j \geq n-1$ whereas you used this property for $j \leq n-1$. This doesn't work.

Another solution: [...] $\sum_0^N E(X_n1_{(T=n)}|\mathcal{F}_0) = \sum_0^N 1_{(T=n)} E(X_n | \mathcal{F}_0)$

This identity does not hold true. You cannot simply pull $1_{\{T=n\}}$ outside the expectation because $1_{\{T=n\}}$ is not $\mathcal{F}_0$-measurable.
