Deriving a conditional Black-Scholes formula Apologies if the title is poorly worded, I wasn't sure how to phrase it.
I am trying to derive the Black-Scholes formula for a call option with an added condition. The condition is that there is some time $T_0$ between $t=0$ and the option's maturity date $T$, and that the buyer may only buy a stock at maturity at the strike price $K$ if the price of the stock at time $T_0$ is greater than some $K_0>0$. If $S(T_0)<K_0$, that is if the stock price at $T_0$ is less than $K_0$, the buyer may not buy anything.
I know in the standard Black-Scholes derivation, if $S(T)=x$, the option is worth $g(x)=(x-K)^+$ at maturity. My first guess has been to add an indicator function $h(T_0)$ to the terminal value function $g(x)$ such that $h(T_0)=1$ when $S(T_0)>K_0$ and $0$ if not, and proceed with the derivation of the formula from there. 
However, I'm unsure if this is even the right course of action, and if so I'm not entirely sure how to calculate the risk neutral expectation and variance of the stock from there.
 A: I think what you say seems correct. You just need to compute the conditional expectation (under the risk neutral measure) of $(S(T)-K)_+ 1_{\{S(T_0)>K_0\}}$. Now depending on whether $t<T_0$ or $t>T_0$ you can take out the indicator function out of the expectation or not by measurability. In the case that you can not things get trickier but not a big deal since you can separate $(S(T)-K)_+$ as
$$(S(T)-K)_+ =(S(T)-K) 1_{\{S(T)>K\}}$$
And now the product of indicator functions is the indicator that both events occur:
$$1_{\{S(T)>K\}}1_{\{S(T_0)>K_0\}}=1_{\{S(T)>K,S(T_0)>K_0\}}$$
From here you may use the same trick that $S(T)/S(t)$ and $S(T_0)/S(t)$ are independent of $S(t)$. But, careful, they are not independent of each other. So you may need to condition your expectation on both $S(T_0)$ and $S(t)$ (the latter only if you want to find the price at any time $t$). Maybe also by writing: $S(T)=S(T)/S(T_0)* S(T_0)/S(t)*S(t)$ and use independence to compute the expectation by conditioning.
Hope it helped.
I add more details here but I assume $r=0$ for notational simplicity, you have to add $e^{-t(T-t)}$ for discounting: If $0<T_0<t<T$ then $1_{\{S(T_0)>K_0\}}$ has been observed and we have under the risk neutral measure $Q$:
$$p(t) = E_Q [(S(T)-K)_+ 1_{\{S(T_0)>K_0\}}|\mathcal{F}_t]=1_{\{S(T_0)>K_0\}}E_Q [(S(T)-K)_+|\mathcal{F}_t]$$
which is either 0 or equal to the usual Black-Scholes price if $S(T_0)>K_0$ obviously. Hence, the interesting part is when $0<t<T_0<T$ and $S(T_0)$ has yet not been observed. Observe that
$$\frac{S(T)}{S(t)} = e^{\left(\mu-\frac{1}{2}\sigma^2\right)(T-t)+\sigma (W_T-W_t)},$$
where $W$ is the driving Brownian noise in $S$. In the above you can see that $W_T-W_t$ is independent of $W_t$ and hence $S(T)/S(t)$is independent of $S(t)$ for any $0\leq t<T$. We can thus condition on $S(T_0)$ and use this fact:
\begin{align*}
p(t) &= E_Q [(S(T)-K)_+ 1_{\{S(T_0)>K_0\}}|\mathcal{F}_t]=E_Q [(S(T)-K) 1_{\{S(T)>K,S(T_0)>K\}}|\mathcal{F}_t]\\
&=E_Q [S(T)1_{\{S(T)>K,S(T_0)>K_0\}}|\mathcal{F}_t]-KE_Q [ 1_{\{S(T)>K,S(T_0)>K_0\}}|\mathcal{F}_t] \\
\end{align*}
I explain the first one a little bit then you can do the second term: now writing $S(T)=\frac{S(T)}{S(t)}S(t)$ and $S(T_0)=\frac{S(T_0)}{S(t)}S(t)$ we can write:
\begin{align*}
E_Q [S(T)1_{\{S(T)>K,S(T_0)>K\}}|\mathcal{F}_t] = S(t) E_Q [\frac{S(T)}{S(t)}1_{\{\frac{S(T)}{S(t)}>\frac{K}{S(t)},\frac{S(T_0)}{S(t)}>\frac{K_0}{S(t)}\}}|\mathcal{F}_t] \\
\end{align*}
where I took $S(t)$ out of the expectation since $S(t)$ is $\mathcal{F}_t$-measurable. Now everything in the expectation is independent of $\mathcal{F}_t$ so we can just compute:
\begin{align*}
S(t) E_Q [\frac{S(T)}{S(t)}1_{\{\frac{S(T)}{S(t)}>\frac{K}{S(t)},\frac{S(T_0)}{S(t)}>\frac{K_0}{S(t)}\}}]
\end{align*}
which is a usual expectation. The rest is analogous to the derivation of the Black-Scholes formula via expectation: change from $Q$to $P$ (Girsanov) and use that $\log(\frac{S(T)}{S(0)})$ are normally distributed
\begin{align*}
S(t) E_Q [\frac{S(T)}{S(t)}1_{\{\frac{S(T)}{S(t)}>\frac{K}{S(t)},\frac{S(T_0)}{S(t)}>\frac{K_0}{S(t)}\}}]=S(t) E_Q [\frac{S(T)}{S(t)}1_{\{\log(S(T)/S(0))>\log(K/S(0)),\log(S(T_0)/S(0))>\log(K_0/S(0))\}}]
\end{align*}
and now you can proceed, but! careful here, because the normally distributed random variables $\log(S(T)/S(0))$ and $\log(S(T_0)/S(0))$ are not independent, so you may need to derive the bivariate density of $(\log(S(T)/S(0)),\log(S(T_0)/S(0)) )$ or use the trick $\log(S(T)/S(T_0)*S(T_0)/S(0))$ and $\log(S(T_0)/S(0))$ and here $S(T)/S(T_0)$ is independent of $S(T_0)/S(0)$ so you can condition on $S(T_0)/S(0)$ first, compute the expectation w.r.t. $S(T)/S(T_0)$ first letting $S(T_0)/S(0)$ be untouched, then average further $S(T_0)/S(0)$.
