You can also use tapplya group constructed from diff, abs, signand cumsum.
Using db data, the result
unname(tapply(x, cumsum(c(0, abs(diff(sign(x))))), sum))
[1] 24 -17 6 -35 29 -10 4 -17 14 -19 15 -9
Sign-1, 1 0 . diff , , abs diff , , cumsum tapply.