Candlestick Charts in R
[This article was first published on R – Predictive Hacks, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.
We have written many posts related to stocks. A good way to represent the stock prices as time series is with Candlestick Charts.
![Candlestick Charts in R 1](https://i0.wp.com/upload.wikimedia.org/wikipedia/commons/thumb/e/ea/Candlestick_chart_scheme_03-en.svg/2880px-Candlestick_chart_scheme_03-en.svg.png?w=578&ssl=1)
Let’s see how we can easily produce candlestick charts with R. We will work with the quantmod
library and with the AMZN
stock.
library("quantmod") # get the Amazon Stock data Amazon<-getSymbols("AMZN", from = "2020-01-01", to = "2021-03-17", periodicity = "daily", auto.assign=FALSE) chartSeries(Amazon, name="Amazon Chart")
![Candlestick Charts in R 2](https://i2.wp.com/predictivehacks.com/wp-content/uploads/2021/03/image-55-1024x661.png?w=450&ssl=1)
chartSeries(Amazon, name="Amazon Chart", subset = "last 2 months")
![Candlestick Charts in R 3](https://i1.wp.com/predictivehacks.com/wp-content/uploads/2021/03/image-56-1024x661.png?w=450&ssl=1)
chartSeries(Amazon, name="Amazon Chart", subset = "2021", theme="white")
![Candlestick Charts in R 4](https://i1.wp.com/predictivehacks.com/wp-content/uploads/2021/03/image-57-1024x661.png?w=450&ssl=1)
To leave a comment for the author, please follow the link and comment on their blog: R – Predictive Hacks.
R-bloggers.com offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.