Hi there !
Sorry for the delayed answer.
The reason of non exit is explained by the following block:
The variable "pos" doesn't have neither static value nor dynamic: so the system is interpreting this as an unknown value and comparing it with 0 is simply impossible. Therefore the exit is blocked.
Besides, I noticed the use of OnTick method while you seems to want to trade on 15mn candles. I've changed that in the attached version. Also, there is a redundancy when checking the number of open positions...So I removed the additional IF
Cheers !