Here is a few references about OBV calculations:
- http://ta.mql4.com/indicators/volumes/on_balance_volume
- http://stockcharts.com/school/doku.php?id=chart_school:technical_indicators:on_balance_volume_obv
- http://en.wikipedia.org/wiki/On-balance_volume
When I navigate to the source code of OBV function in TTR package, I see this:
"OBV" <-
function(price, volume) {
# On Balance Volume
price <- try.xts(price, error=as.matrix)
volume <- try.xts(volume, error=as.matrix)
if(!(is.xts(price) && is.xts(volume))) {
price <- as.vector(price)
volume <- as.vector(volume)
}
obv <- c( volume[1], ifelse( ROC(price) > 0, volume, -volume )[-1] )
obv <- cumsum( obv )
if(is.xts(obv)) {
obv <- xts(obv,index(price))
colnames(obv) <- 'obv'
}
reclass( obv, price )
}
I see that the equality case (I mean the case occurs when today’s close is equal to yesterday’s close) in the reference web pages does not exist in OBV function implementation.
Is it a bug or an acceptance of the package? If it is a bug, where can I report the issue?