Wearable sensors, including accelerometers, are a widely accepted tool to assess gait in clinical and free-living environments. Methods to identify phases and subphases of the gait cycle are necessary for comprehensive assessment of pathological gait. The current study evaluated the accuracy of a finite state machine (FSM) algorithm to detect strides by identifying gait cycle subphases from ankle-worn accelerometry. Algorithm performance was challenged across a range of speeds (0.4-2.6 m/s), task conditions (e.g., single- and dual-task walking), and individual characteristics. Specifically, the study included a range of treadmill speeds in young adults and overground walking conditions in older adults with neurological disease. Manually counted and algorithm-derived stride detection from acceleration data were evaluated using error analysis and Bland-Altman plots for visualization. Overall, the algorithm successfully detected strides (>96% accuracy) across gait speed ranges and tasks, for young and older adults. The accuracy of an FSM algorithm combined with ankle-worn accelerometers, provides an analytical approach with affordable and portable tools that permits comprehensive assessment of gait unbounded by setting and proves to perform well in in walking tasks characterized by variable walking. These algorithm capabilities and advancements are critical for identifying phase dependent gait impairments in clinical and free-living assessment.