how to write trade no more than twice in an hour? please!

how to write trade no more than twice in an hour
use curTime - last trading time >3600 should be ok