[R-SIG-Finance] quantstrat add.indicator change (mktdata) to (mktdata)[, 1]

Brian G. Peterson brian at braverock.com
Sat Apr 13 23:20:03 CEST 2013


On 04/13/2013 03:51 PM, Rob Schmidt wrote:
> As the world marches forward, my newbie quantstrat examples have become
> broken.  (How dare they change anything!)  I was unaware, so thanks to Scott
> Schmidt for pointing out that functions of mktdata in the add.indicator
> command now have a column specified.  For example Cl(mktdata) becomes
> Cl(mktdata)[,1].  Also we should update to the latest versions like I
> finally did.

It would be more accurate to say that moving average functions in TTR 
now paste the MA type and periodicity onto the name of the data they are 
passed.

So, if you have and xts OHLC object called x, with standard 
getSymbols-style naming, it would have a column called x.Close.

If you extract that column with Cl(x) as input to SMA(Cl(x),20), you'll 
get back a column called x.Close.SMA.20.  The quantstrat indicators code 
will cbind that to mktdata

If you now call Cl(mktdata), you'll get two columns back: x.Close and 
x.Close.SMA.20.

So now you need to specify which one you want in later operations.

Regards,

   - Brian

-- 
Brian G. Peterson
http://braverock.com/brian/
Ph: 773-459-4973
IM: bgpbraverock



More information about the R-SIG-Finance mailing list