Candlestick Chart
ggplot2: geom_candlestick() · Package: tidyquant · Variables: 1 temporal + 4 numerical (OHLC)
WHAT IS A CANDLESTICK CHART?
A candlestick chart is the standard chart for financial price data, showing four values per time period: open, high, low, and close (OHLC). Each "candle" has a body (open-to-close range) and wicks (high-low range). Green/hollow candles indicate price increases, red/filled candles indicate decreases. Candlestick charts are essential for stock trading, commodity analysis, and technical analysis patterns. They answer "what was the price action for each period?" In R, the tidyquant package provides geom_candlestick() for ggplot2 integration with financial data sources.
BEST FOR
- · Stock/commodity price analysis
- · Price range and direction
- · Technical analysis
AVOID WHEN
- · Non-financial data
- · Audience unfamiliar with financial charts
- · When only closing price matters
R + GGPLOT2 CODE EXAMPLE
library(tidyquant)
AAPL <- tq_get("AAPL", from = "2024-01-01", to = "2024-06-01")
ggplot(AAPL, aes(x = date, y = close)) +
geom_candlestick(aes(open = open, high = high, low = low, close = close)) +
labs(title = "AAPL Candlestick Chart", x = "Date", y = "Price")Run this code now
Paste the code above into RChat and see the candlestick chart rendered instantly in your browser.