Search code examples
rquantmod

newTA SMA OBV How to?


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.


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))