In vaccine safety studies, subjects are considered at increased risk for adverse events for a period of time after vaccination known as risk window. To our knowledge, risk windows for vaccine safety studies have tended to be pre-defined and not to use information from the current study. Inaccurate specification of the risk window can result in either including the true control period in the risk window or including some of the risk window in the control period, which can introduce bias. We propose a data-based approach for identifying the optimal risk windows for self-controlled case series studies of vaccine safety. The approach involves fitting conditional Poisson regression models to obtain incidence rate ratio estimates for different risk window lengths. For a specified risk window length (L), the average time at risk, T(L), is calculated. When the specified risk window is shorter than the true, the incidence rate ratio decreases with 1/T(L) increasing but there is no explicit relationship. When the specified risk window is longer than the true, the incidence rate ratio increases linearly with 1/T(L) increasing. Theoretically, the risk window with the maximum incidence ratio is the optimal risk window. Because of sparse data problem, we recommend using both the maximum incidence rate ratio and the linear relationship when the specified risk window is longer than the true to identify the optimal risk windows. Both simulation studies and vaccine safety data applications show that our proposed approach is effective in identifying medium and long-risk windows. Copyright © 2010 John Wiley & Sons, Ltd.