Both ATR() and optimize() must be called consistently, either always or never. You can skip trading dependent on time, but you cannot skip ATR() and optimize(). - For preventing a stop at night, the only way is handling the stop with a TMF. Otherwise a stop would be always executed since it's an event with high priority.