[R-SIG-Finance] help with quantmod and addTA

Olivier MARTIN Olivier.Martin at avignon.inra.fr
Fri Aug 10 20:43:04 CEST 2012


Hi all,

I don't understand very well the principles of oriented
programmation and I have some diffculties with the function addTA().

I suppose I have plotted a time serie with the function candleChart() 
for example.
I have a vector y with 1,-1 and 0 values with the same length than my serie.
If i want to add a shaded region corresponding to the value 1, I can do 
it with
addTA(y==1,col="gray90",border=NA,on=-1)

So I would like to write a function that add the three different regions
I tried this
addshaded=function(x){
addTA(x==1,col="gray90",border=NA,on=-1)
addTA(x==-1,col="green",border=NA,on=-1)
addTA(x==0,col="red",border=NA,on=-1)
}

But the command addshaded(y) does not add the three different
shaded regions. ;-(

Regards,
Olivier.



More information about the R-SIG-Finance mailing list