Is it possible to create a hold range?

Im having trouble getting a backtested portfolio to buy companies at a PE of below 10, hold them until 20 and then sell them.
Does anyone know how I might code this in?

Thanks,
Sorry for the basic ass question.

in a simulation, use the buy rule PEExclXorTTM < 10 and the sell rule PEExclXorTTM > 20.

Thank you, really appreciate it.