Description Usage Arguments Value Examples
This function plots the log of prices and highlights bear states
1 |
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
1 2 3 4 5 6 7 8 9 10 | {
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
}
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.