Yes, it's called a
10b5-1 safe harbor. There is no specific time that it has to be set in advance, just that if the executive routinely has access to non-public material information, it has to be in place far enough in advance that they cannot plan things like "sell on May 23". The actual terms of sales can be quite formulaic, too. For example, someone noted that one of the execs normally sells some shares each month but didn't this month (don't remember details, don't have time to look them up), but the trading plan might say "I'll sell 500 shares on the second tuesday each month so long as the price is above $300", or "I'll place a $300 limit sell order" or something like that. The charts could actually support such an idea, we often see quite flat trading around some even numbers.