rtsplot.polygon | R Documentation |
Add polygon to time series plot
rtsplot.polygon(y, col = graphics::par("col"), ...)
y |
|
col |
color, defaults to par('col') |
... |
additional parameters to the |
nothing
y = rtsplot.fake.stock.data(1000, ohlc=TRUE)
symbol = 'SPY'
# moving average
bbands = TTR::BBands(quantmod::HLC(y), n=200, sd=1)[,c('up','dn')]
# plot
layout(1)
rtsplot(y, type = 'l', col='black')
col = grDevices::adjustcolor('green', 50/255)
rtsplot.polygon(bbands, col = col)
rtsplot.legend(c(symbol, 'BBands'), c('black', col), list(y,bbands))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.