One important question in earthquake prediction is whether a moderate or large earthquake will be followed by an even bigger one. Through temporalb-value evolution analysis, the traffic light system can be used to estimate if an earthquake is a foreshock. However, the traffic light system does not take into account the uncertainty ofb-values when they constitute a criterion. In this study, we propose an optimization of the traffic light system with the Akaike Information Criterion (AIC) and bootstrap. The traffic light signals are controlled by the significance level of the difference inb-value between the sample and the background rather than an arbitrary constant. We applied the optimized traffic light system to the 2021 Yangbi earthquake sequence, which could be explicitly recognized as foreshock–mainshock–aftershock using the temporal and spatial variations inb-values. In addition, we used a new statistical parameter related to the distance between earthquakes to track earthquake nucleation features. We also confirmed that the optimized traffic light system works on a high-resolution catalog that includes small-magnitude earthquakes. The comprehensive consideration ofb-value, significance probability, and seismic clustering might improve the reliability of earthquake risk judgment.