As far as I can see, there are no SEC rules specifically about the opening and closing of Trading Windows. Instead, they are set in a company's Insider Trading Policy document: typically, they tend to open a couple of days after major announcements (e.g. of annual or quarterly earnings) and generally last between two and six weeks. For certain senior employees, Trading Windows are the only times that they are permitted to buy or sell stock in their company.
What is a Trading Window?
Trading Windows are part of the "defense mechanism" companies put in place to allow employees (particularly senior ones) to buy or sell stocks in the company without falling foul of the general prohibition on Insider Trading. The scope of what constitutes insider trading is quite pervasive; quoting from the Insider Trading Policy of Premier, Inc [PDF]:
E. Twenty-Twenty Hindsight
If securities transactions ever become the subject of scrutiny, they are likely to be viewed after the fact with the benefit of hindsight. As a result, before engaging in any transaction relating to the Company Securities an insider should carefully consider how such person’s transaction may be construed in the bright light of hindsight.
Therefore, most companies have strict policies governing when and how employees are allowed to trade to try to ensure that any such trades cannot be viewed – after the fact and with 20-20 vision – as "insider trading". Insider trading rules prohibit anyone within a company who may have knowledge of Material Non-Public Information (MNPI) – information that other shareholders and the general public are not in possession of and that may have a material effect on stock price – from acting on that information.
However, for certain higher-level staff (typically board members, officers of the company, members of disclosure, compliance and finance departments etc.) most companies take things one step further and prohibit any trading except within designated Trading Windows. Partly this is because such staff are likely to have frequent knowledge of, or access to, MNPI, and partly to give the wider public a chance to act on information as it is made public. For example, the Insider Trading Policy of NVEnergy [PDF] includes:
5.10 Timing of trading in Securities by Insiders
Because the Company's shareholders and the investment public should be afforded a reasonable amount of time to receive and act on newly released information, as a general rule, Insiders should not engage in any transactions until the second Trading Day following the date of public disclosure, or at such time as the nonpublic information is no longer material.
When is the Trading Window Open?
Evidence that the timing of Trading Windows is not set by the SEC comes from the fact that different companies have different periods written into the various Insider Trading policies. The previously quoted NVEnergy's policy has (some emphasis mine):
3.2 What is the "Trading Window" and when is it open?
The Trading Window designates the permissible timeframes in which individuals in the Trading Window Group and Section 16 Insiders may buy or sell company securities following an earnings release. Generally, the Trading Window opens two business days after quarterly earnings are released and remains open for 30 calendar days thereafter.
Whereas the also previously quoted Premier's policy has (emphasis mine):
A. Trading Window
In addition to being subject to all of the other limitations in this Policy, directors and executive officers of the Company may only buy or sell Company Securities in the public market during the period beginning two full trading days after the release of the Company’s quarterly earnings (by press release or filing of a Form 8-K current report) and ending one calendar month prior to the end of the next fiscal quarter.
On the other hand, TherapeuticsMD, Inc.'s policy has (emphasis mine):
Trading Window Periods.
[...] all employees at the Vice President level and above, as well as all employees in the accounting group are prohibited from buying or selling Company securities at all times, except during the period extending from the third (3rd) through the thirteenth (13th) business day following the release of the Company's earnings for the immediately preceding fiscal period to the public (the "Trading Window Period"). The prohibition on trading in Company securities by such persons at all times other than the Trading Window Period is designed to prevent any inadvertent trading by such persons in the Company's securities during times when there may be material financial information about the Company that has not been publicly disclosed.
Variations and Exceptions
Most companies seem to reserve the right to temporarily vary the opening times of the Trading Window, should there be a need. Also, some companies impose additional requirements: NVEnergy's policy – as well as restricting senior staff to only trading during an open window – also requires them to seek pre-aproval of any trades they intend carrying out during that window.
The restrictions of the Trading Window generally do not apply to trades made under a Rule 10b5-1 Plan (see article on Investopedia). This is an SEC-approved scheme where directors and the like can "distance" themselves from the dangers of being accused of insider trading. Essentially – at a time when they have no MNPI – they can create written instructions covering periodic trading that can then be enacted at a later date (generally by a third-party) without the fear that the trade was made based on insider knowledge.
The Trading Window restrictions generally also do not apply to the exercising of stock option plans (i.e. being granted stock, perhaps at a beneficial price). However, the restrictions would apply to the sale of any stock acquired under such plans.