bb.plot {bbdetection} | R Documentation |
This function plots the log of prices and highlights bear states
bb.plot(price, bull, dates, price.name=NULL, log.scale=TRUE)
price |
a numeric vector of price values |
bull |
a logical vector that contains the states of the market. This vector
is returned by function |
dates |
a vector of dates in Date format |
price.name |
the name of the time-series of prices that will appear on the y-axis of the plot |
log.scale |
a logical variable that specifies whether to use log scale along the y-axis |
None
{ library(zoo) library(xtable) library(ggplot2) price <- as.vector(coredata(sp500m)) # retrieve monthly prices dates <- index(sp500m) # retrieve dates from zoo-object setpar_dating_alg(4, 6, 5, 15, 20) # parameters for monthly data bull <- run_dating_alg(price) # detect bull-bear states bb.plot(price, bull, dates, "S&P 500") # plot the result }