Question

I am trying to create a new indicator in R with quantmod's command newTA but i can't make it.

The indicator is a simple 20-day moving average of the OBV.

so far i tried this

getSymbols("GEK.AT")
addObvma20 <- newTA(SMA(OBV(Cl(GEK.AT), Vo(GEK.AT)), n=20))
# Error in newTA(SMA(OBV(Cl(GEK.AT), Vo(GEK.AT)), n = 20)): FUN required
# to be a function object

and this

addObvma20 <- newTA(SMA(OBV), n=20)
# Error in as.vector(x, mode):cannot coerce type 'closure' to vector of type 'any' 

I would like some help creating this indicator.

Was it helpful?

Solution

Adapting the example from the help page, I think you want addTA rather than newTA.

getSymbols("GEK.AT")
barChart(GEK.AT)
addTA(SMA(OBV(Cl(GEK.AT), Vo(GEK.AT)), n = 20))
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top