5.12 Custom indicators
The following code shows filter below the price chart:
Filter <- function(price){
r <- price/lag(price,1)
return(r)
}
filter <- Filter(Cl(AAPL))
chartSeries(AAPL,
subset='2007-05::2009-01',
theme=chartTheme('white'))
addTA(filter, col="red")
To show it on the price chart, we use the option on=1. Here, I am using a completely makeup indicatior that is average ot 30-day SMA and 40-day EMA.