For example: A non-dividend paying stock is currently priced at $20, and you hold a put that allows early exercise in 2 months and in 4 months. The option expires in 6 months. Volatility is 30%, and r = 5%. What is the value of this option?
I know with the payoff at time T with shout option is $Max(S_T - K, S_\tau-K, 0)$, which can be expressed as $Max(S_T-S_\tau, 0) + (S_\tau -K)$. Now we have a new strike value $S_T-S_\tau$, and we know that $S_\tau$ has to be greater than $K$. We can use the CRR binomial model with parameters: $u = e^{\sigma \sqrt{dt}} = 1.0905, d = e^{-\sigma \sqrt{dt}}=0.9170, and p = \dfrac{e^{r(dt)}-d}{u-d}=0.5024$. We can use the $Max(ST−Sτ,0)$ to find the payoff. I'm not sure if it is correct? And how do we find when we shout for the optimal payoff by algorithm(C++)? Thank you very much!