Learn R Programming

rtsplot (version 0.1.5)

rtsplot.polygon: Add polygon to time series plot

Description

Add polygon to time series plot

Usage

rtsplot.polygon(y, col = graphics::par("col"), ...)

Value

nothing

Arguments

y

xts object with 2 columns

col

color, defaults to par('col')

...

additional parameters to the lines

Examples

Run this code
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))

Run the code above in your browser using DataLab