Did you check the comments for OMNeT's simtime dbl() function?
/**
* Converts simulation time (in seconds) to a double. Note that conversion to
* and from double may lose precision. We do not provide implicit conversion
* to double as it would conflict with other overloaded operators, and would
* cause ambiguities during compilation.
*/
This loss of precision might be the case why comparisons against a value might not work.
If you want exact value comparisons, you need to use the simtime_t type (eventually the SimTime class).
Did you also check that your if-condition is actually checked at times where the entering into the loop is actually possible (does the if X == TRUE case actually occur)?