on line 10 of the function:
obv <- c(volume[1], ifelse(prChg > 0, volume, -volume)[-1])
in the case that both price and volumn argument is a numeric vector, volume[1] will return an 2d xts object but ifelse will return a numeric vector, which will return error if you combine them using c()
on line 10 of the function: obv <- c(volume[1], ifelse(prChg > 0, volume, -volume)[-1])
in the case that both price and volumn argument is a numeric vector, volume[1] will return an 2d xts object but ifelse will return a numeric vector, which will return error if you combine them using c()