As mentioned the length error occurs because you pass the wrong type/format as window. It's supposed to be a pair of lists. Please review the syntax here https://code.kx.com/q/ref/wj/ Also, you're probably interested in wj1 rather than wj as wj includes the prevailing data point whereas wj1 only considers the data points within the time window