I stumbled upon this chart in the R Graph Gallery, which got me thinking someone could come up with a Volume by Price chart using R.
Such charts can be useful to determine support and resistance levels, as they illustrate amount of volume for different price ranges.
Below is my first attempt at this. Note that
1. the left axis (price) is not perfectly aligned and doesn’t show up properly
2. the horizontal barplot could be upgraded to a stacked barplot identifying which part of the volume came from a up/down price movement.
library(quantmod)
sumVol <- function(x) {
sum(Vo(subset(GSPC, GSPC$t == x)))
}
getSymbols("^GSPC")
hi <- hist(Cl(GSPC), plot=F)
b <- hi$breaks
GSPC$t <- floor(Cl(GSPC)/ 100) * 100
vols <- unlist(lapply(b, sumVol))
t <- as.table(vols)
names(t) <- b
plot(GSPC, col='red')
par(new=T)
barplot(t, horiz=T, axes=F, col=rgb(0.1,0.7,0.1,alpha=0.1)) |


Eric,
You have made this chart creation look so simple! Congrats
Inspired from this post, I have made similar efforts to overcome the shortcomings mentioned in your post
Cheers
Posted by MA | November 23, 2011, 5:24 amThanks! I just went through your post on this topic, and I’m linking it here for completion. Nice work!
http://mypapertrades.blogspot.com/2011/11/r-bloggers-is-wonderful-site-which.html
Posted by enguyen | November 30, 2011, 7:46 pmI’ve looked at the graph for a while now and I have to ask can you explain how to interpret the chart.
Posted by John | April 29, 2012, 12:24 am