
Hi guys,

In each iteration of my loop, we change the ohlc object "kk" to generate a movie of evolving  (and generating new) ohlc-

bars via the chartSeries command:

 chartSeries(kk,type="bars")

 Now I wanted add to this movie a movie of the RSI, whose most recent value changes as the respective close of the most 

recent bar changes. This I did via the command

 chartSeries(kk,type="bars", TA='addRSI()')


 However, the graphical representation does not satisfy me, you barely see the RSI window, it sometimes shows up but 

quickly disappears afterwards.

Here is the full code:

require(quantmod)
options(digits=3)
jjtest <- getSymbols('SVU', auto=FALSE)
chartSeries(head(jjtest), type="bars")
jjtest2 <- jjtest[, 1:4]
jjtest3<-head(jjtest2,5)


z<-jjtest3[1,1:4]
z[]<-jjtest3[1,1]
index(z)<-Sys.time()

y<-jjtest3[1,1:4]
y[]<-jjtest3[1,1]
index(y)<-Sys.time()

for(i in 1:2){index(z)<-Sys.time()+i; y<-rbind(y,z)}


#Update of Chart via Range Bar logic
fjj.newdat <- function(x, range=.3, sd=.01) {
  nrx <- nrow(x)
  last <- x[nrx, 4]
  new <- round(last + rnorm(1, sd=sd),2)
  if(x[nrx, 2] - new > range || new - x[nrx,3] > range) {
    newr <- x[1,]
    newr[] <- new
    index(newr) <- Sys.time()+3
    x <- rbind(x, newr)
  } else {
    x[nrx,4] <- new
    if(new > x[nrx,2]) {
      x[nrx,2] <- new
    } else if(new < x[nrx,3]) {
      x[nrx,3] <- new
    }
  }
  x
}
#end of Range Bar logic

jj <- y; for(i in 1:80000) {
    jj <- fjj.newdat(jj)

    if(nrow(jj)<5){
        chartSeries(jj, type='bars',theme=chartTheme("white"))
    } else{
        kk<-jj[3:nrow(jj),]
        if(nrow(kk) <= 14) {
            chartSeries(kk,type="bars",theme=chartTheme("white"))
        } else {
            chartSeries(kk,type="bars", TA='addRSI()',theme=chartTheme("white"))
            #Sys.sleep(0.5)
        }
    }
 if(FALSE) {
    if(nrow(kk)>15){
        plot(addRSI())
        if(nrow(kk)>27){
            plot(addMACD())
        }
        if(nrow(kk)>21){
            plot(addBBands())
        }
    }
 }
}

Any help would be very much appreciated!

Kind regards,
Andreas Swoboda
 		 	   		  
	[[alternative HTML version deleted]]

