[R-SIG-Finance] Interesting issue in MACD calculation
Joshua Ulrich
josh.m.ulrich at gmail.com
Mon Jul 9 00:55:00 CEST 2012
On Sun, Jul 8, 2012 at 5:35 PM, Raghuraman Ramachandran
<optionsraghu at gmail.com> wrote:
> Dear guRus
>
> A very simple issue that I thought I will bring to your notice.
>
> I have a dataframe called testdata:
> str(testdata)
> 'data.frame': 748 obs. of 5 variables:
> $ Date : Date, format: "2009-07-13" "2009-07-14" ...
> $ Open : num 750 760 793 810 794 ...
> $ High : num 764 802 811 832 821 ...
> $ Low : num 725 760 792 786 790 ...
> $ Close: num 758 790 807 795 811 ...
>
> When I calculate MACD using the TTR on the closes I get a value which is
> different from what I get when I convert the same object into XTS. (-2.33
> when a simple dataframe and 4.82 for xts). I am using percent=FALSE in both
> cases.
It is extremely difficult to help diagnose odd results like this
without a minimal reproducible example. See this question on Stack
Overflow for instructions to create a minimal reproducible example:
http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example
> To get to the root of the issue I tried an excel run of the same and to my
> surprise my MACD using Excel is different.
>
> Wondering which is the truth! Intuitively I think the xts result is
> correct. I even tried doing an EMA12-EMA26 on the non-xts and still got the
> different answer of -2.33.
>
> I was thinking I will attach the excel here but not sure if its an
> allowable conduct in a large forum.
>
This is an R forum, so please do not attach an Excel file.
> Thx for looking
> Raghu
>
> [[alternative HTML version deleted]]
>
> _______________________________________________
> R-SIG-Finance at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-sig-finance
> -- Subscriber-posting only. If you want to post, subscribe first.
> -- Also note that this is not the r-help list where general R questions should go.
Best,
--
Joshua Ulrich | FOSS Trading: www.fosstrading.com
More information about the R-SIG-Finance
mailing list