| Title: | Pipe-First TradingView Lightweight Charts for Quantmod Workflows |
|---|---|
| Description: | Wraps TradingView's lightweight-charts library as an htmlwidgets package with a pipe-first API designed around quantmod, xts, and common trading workflows. |
| Authors: | Alex Kraieski [aut, cre] |
| Maintainer: | Alex Kraieski <[email protected]> |
| License: | GPL-3 |
| Version: | 0.1.1 |
| Built: | 2026-05-17 05:17:47 UTC |
| Source: | https://github.com/arkraieski/lightweightchartR |
Add an area series from a chart column
add_area(chart, column = NULL, pane = "price", name = NULL, color = "#0f766e")add_area(chart, column = NULL, pane = "price", name = NULL, color = "#0f766e")
chart |
A |
column |
Source column. Defaults to the close column. |
pane |
Target pane. |
name |
Optional series name. |
color |
Series color. |
The updated chart object.
Add OHLC bars from chart data
add_bars( chart, pane = "price", name = "Bars", up_col = "#26a69a", down_col = "#ef5350" )add_bars( chart, pane = "price", name = "Bars", up_col = "#26a69a", down_col = "#ef5350" )
chart |
A |
pane |
Target pane. |
name |
Optional series name. |
up_col, down_col
|
Rising and falling colors. |
The updated chart object.
Add Bollinger Bands
add_bbands( chart, n = 20, sd = 2, column = NULL, pane = "price", color = "#7c3aed", ... )add_bbands( chart, n = 20, sd = 2, column = NULL, pane = "price", color = "#7c3aed", ... )
chart |
A |
n |
Window size. |
sd |
Number of standard deviations. |
column |
Source column. Defaults to the close column. |
pane |
Target pane. |
color |
Series color. |
... |
Reserved for future extensions. |
The updated chart object.
Add candlesticks from chart data
add_candles( chart, pane = "price", name = "Candles", up_col = "#26a69a", down_col = "#ef5350" )add_candles( chart, pane = "price", name = "Candles", up_col = "#26a69a", down_col = "#ef5350" )
chart |
A |
pane |
Target pane. |
name |
Optional series name. |
up_col, down_col
|
Rising and falling colors. |
The updated chart object.
Add an exponential moving average
add_ema(chart, n = 20, column = NULL, pane = "price", color = "#ea580c", ...)add_ema(chart, n = 20, column = NULL, pane = "price", color = "#ea580c", ...)
chart |
A |
n |
Window size. |
column |
Source column. Defaults to the close column. |
pane |
Target pane. |
color |
Series color. |
... |
Reserved for future extensions. |
The updated chart object.
Add a histogram series from a chart column
add_histogram( chart, column = NULL, pane = "histogram", name = NULL, color = "#7c3aed", pane_height = 1 )add_histogram( chart, column = NULL, pane = "histogram", name = NULL, color = "#7c3aed", pane_height = 1 )
chart |
A |
column |
Source column. Defaults to the close column. |
pane |
Target pane. |
name |
Optional series name. |
color |
Series color. |
pane_height |
Relative pane height for the target pane. |
The updated chart object.
Add a line series from a chart column
add_line(chart, column = NULL, pane = "price", name = NULL, color = "#2563eb")add_line(chart, column = NULL, pane = "price", name = NULL, color = "#2563eb")
chart |
A |
column |
Source column. Defaults to the close column. |
pane |
Target pane. |
name |
Optional series name. |
color |
Series color. |
The updated chart object.
Add MACD in a separate pane by default
add_macd( chart, nFast = 12, nSlow = 26, nSig = 9, column = NULL, pane = "macd", pane_height = 1, ... )add_macd( chart, nFast = 12, nSlow = 26, nSig = 9, column = NULL, pane = "macd", pane_height = 1, ... )
chart |
A |
nFast, nSlow, nSig
|
MACD periods. |
column |
Source column. Defaults to the close column. |
pane |
Target pane. |
pane_height |
Relative pane height for the RSI pane. |
... |
Reserved for future extensions. |
The updated chart object.
Add RSI in a separate pane by default
add_rsi( chart, n = 14, column = NULL, pane = "rsi", color = "#dc2626", pane_height = 0.8, ... )add_rsi( chart, n = 14, column = NULL, pane = "rsi", color = "#dc2626", pane_height = 0.8, ... )
chart |
A |
n |
Window size. |
column |
Source column. Defaults to the close column. |
pane |
Target pane. |
color |
Series color. |
pane_height |
Relative pane height for the RSI pane. |
... |
Reserved for future extensions. |
The updated chart object.
Add a simple moving average
add_sma(chart, n = 20, column = NULL, pane = "price", color = "#2563eb", ...)add_sma(chart, n = 20, column = NULL, pane = "price", color = "#2563eb", ...)
chart |
A |
n |
Window size. |
column |
Source column. Defaults to the close column. |
pane |
Target pane. |
color |
Series color. |
... |
Reserved for future extensions. |
The updated chart object.
Add a generic indicator or comparison series
add_ta( chart, values, type = c("line", "area", "histogram"), pane = "price", name = NULL, color = "#2563eb", pane_height = NULL, overlay = identical(pane, "price") )add_ta( chart, values, type = c("line", "area", "histogram"), pane = "price", name = NULL, color = "#2563eb", pane_height = NULL, overlay = identical(pane, "price") )
chart |
A |
values |
An |
type |
One of |
pane |
Target pane. Defaults to |
name |
Optional display name. |
color |
Optional series color. |
pane_height |
Relative pane height for new panes. |
overlay |
Whether to overlay on the existing price scale. |
The updated chart object.
Add volume bars
add_volume( chart, pane = "price", color_up = "#26a69a", color_down = "#ef5350", pane_height = 0.6 )add_volume( chart, pane = "price", color_up = "#26a69a", color_down = "#ef5350", pane_height = 0.6 )
chart |
A |
pane |
Target pane. Defaults to |
color_up, color_down
|
Colors for rising/falling volume bars. |
pane_height |
Relative pane height for the volume pane. |
The updated chart object.
chart_series_lwc() offers a quantmod-flavored bridge into the pipe-first
chart API. It recognizes a small subset of common chartSeries() and
addTA() workflows.
chart_series_lwc( x, type = c("auto", "candles", "bars", "line", "area"), subset = NULL, show.grid = TRUE, name = NULL, log.scale = FALSE, TA = NULL, theme = c("light", "dark"), up.col = "#26a69a", dn.col = "#ef5350", ... )chart_series_lwc( x, type = c("auto", "candles", "bars", "line", "area"), subset = NULL, show.grid = TRUE, name = NULL, log.scale = FALSE, TA = NULL, theme = c("light", "dark"), up.col = "#26a69a", dn.col = "#ef5350", ... )
x |
Market data. Usually an |
type |
Base series type. |
subset |
Optional quantmod-style subset string, passed through |
show.grid |
Included for API familiarity. Currently ignored. |
name |
Optional display name for the chart. |
log.scale |
Included for API familiarity. Currently ignored. |
TA |
Optional semicolon-delimited TA expressions like
|
theme |
|
up.col, dn.col
|
Rising and falling colors for price series. |
... |
Reserved for future compatibility arguments. |
A lightweightchartR chart widget.
Shiny bindings for lightweightchartR
lightweightchartROutput(outputId, width = "100%", height = "480px") renderLightweightchartR(expr, env = parent.frame(), quoted = FALSE)lightweightchartROutput(outputId, width = "100%", height = "480px") renderLightweightchartR(expr, env = parent.frame(), quoted = FALSE)
outputId |
Output variable to read from. |
width, height
|
CSS dimensions for the widget container. |
expr |
An expression that generates a chart. |
env |
The environment in which to evaluate |
quoted |
Is |
lwc_chart() creates a TradingView lightweight chart widget from xts,
zoo, or data frame inputs. The result is a pipeable chart object that can
be extended with add_*() helpers.
lwc_chart( data, type = c("auto", "candles", "bars", "line", "area"), subset = NULL, name = NULL, theme = c("light", "dark"), width = NULL, height = NULL, elementId = NULL, up_col = "#26a69a", down_col = "#ef5350", ta_tooltip = TRUE, ta_tooltip_threshold = 14 )lwc_chart( data, type = c("auto", "candles", "bars", "line", "area"), subset = NULL, name = NULL, theme = c("light", "dark"), width = NULL, height = NULL, elementId = NULL, up_col = "#26a69a", down_col = "#ef5350", ta_tooltip = TRUE, ta_tooltip_threshold = 14 )
data |
Market data. Usually an |
type |
Base series type. |
subset |
Optional quantmod-style subset string, passed through |
name |
Optional display name for the chart. |
theme |
|
width, height
|
Widget dimensions passed to |
elementId |
Optional element id. |
up_col, down_col
|
Rising/falling color defaults for price series. |
ta_tooltip |
Whether to show hover tooltips for price-pane technical analysis overlays. |
ta_tooltip_threshold |
Pixel distance used to match the pointer to the nearest overlay line for the TA tooltip. |
An htmlwidget object that also supports pipe-based layer helpers.
rechart_lwc() updates global display options on an existing chart.
rechart_lwc(chart, theme = NULL, ...)rechart_lwc(chart, theme = NULL, ...)
chart |
A |
theme |
Optional replacement theme. |
... |
Additional lightweight-charts chart options merged into the existing top-level options. |
The updated chart object.