[R] SMA and EMA in package TTR

Joshua Ulrich josh.m.ulrich at gmail.com
Wed Feb 2 17:57:54 CET 2011


Hi Anyi,

That's not currently possible.  You could use the rollmean function in
the development version of the zoo package (on R-forge) to calculate
the simple moving average as you described.

I would like to add this as an option to TTR functions, but it is not
high on my priority list.  I would appreciate patches.

Best,
--
Joshua Ulrich  |  FOSS Trading: www.fosstrading.com



On Sat, Jan 29, 2011 at 7:39 PM, Anyi Zhu <anyi.zhu at gmail.com> wrote:
> Hi,
>
> Just wondering for the SMA and EMA in package TTR, is it possible to me to
> code it so that, say if I need to calculate SMA (x, n=100), when the sample
> size is less than 100, it will give me the SMA (x, k) where k is the sample
> size of the data? Right now it only gives me an invalid n error.
>
> Thanks!
>
>        [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



More information about the R-help mailing list