Innovative systems and automated computational procedures, such as those based on computer vision or inertial wearable sensors, have recently been adopted to provide effective and accurate monitoring and analysis of cow behaviour and respond to different issues related to cow health and welfare. In this study, a new and open source algorithm, characterised by a linear computational time, was defined and implemented with the aim to improve real-time monitoring and analysis of walking behaviour of dairy cows. It was applied to a novel inertial sensor-based system composed of low-cost devices, including wearable sensors, open source software, operating with a 4-Hz sampling frequency. The algorithm computed the number of steps of each cow from accelerometer data by making use of statistically defined thresholds. Two vector variables were considered to study the accelerometer signals, i.e., Signal Vector Magnitude and Signal Magnitude Area. Algorithm accuracy was carried out by comparing total error (E) and Relative Measurement Error (RME), and a sensitivity analysis on the parameters of the computed thresholds was carried out to analyse the variation of the error made by the algorithm. The results showed that the algorithm produced an E equal to 9.5%, and a RME between 2.4% and 4.8%. The sensitivity analysis confirmed that the proposed thresholds provided the minimum errors and that RME is less suitable than E for measuring the accuracy of the step counter. In fact, the underestimated and overestimated numbers of steps counted by the algorithm tended to compensate each other in RME computation. (c) 2016 IAgrE. Published by Elsevier Ltd. All rights reserved.