The restricted access window (RAW) feature of IEEE 802.11ah aims to significantly reduce channel contention in ultra-dense and large-scale sensor networks. It divides stations into groups and slots, allowing channel access only to one RAW slot at a time. Several algorithms have been proposed to optimize the RAW parameters (e.g., number of groups and slots, group duration, and station assignment), as the optimal parameter values significantly affect performance and depend on network and traffic conditions. These algorithms often rely on accurate estimation of future sensor station traffic. In this paper, we present a more accurate traffic estimation technique for IEEE 802.11ah sensor stations, by exploiting the ‘more data’ header field and cross slot boundary features. The resulting estimation method is integrated into an enhanced version of the Traffic-Adaptive RAW Optimization Algorithm, referred to as E-TAROA. Simulation results show that our proposed estimation method is significantly more accurate in very dense networks with thousands of sensor stations. This in turn results in a significantly more optimal RAW configuration. Specifically, E-TAROA converges significantly faster and achieves up to 23% higher throughput and 77% lower latency than the original TAROA algorithm under high traffic loads.