[R-SIG-Finance] quantmod addTA() How to compute his own indicator ?

Pierre8r pierre8r-gmane at yahoo.fr
Mon Jul 7 21:36:52 CEST 2008


How to compute his own indicator ?
I want to use addTA() from quantmod with my own indicator.
How to compute my own indicator ?

Please give me some full R code sample.

The sample code can be some Moving Average sample code or other I don't care.
For example Close + 1 
I just need something I can start from.



Here some Java code to compute Moving Average.
But the sample code can be simpler.

Java code :

    public double calculate() {
        int endBar = qh.size() - 1;
        int startBar = endBar - length;
        double sma = 0;

        for (int bar = startBar; bar <= endBar; bar++) {
            sma += qh.getPriceBar(bar).getClose();

        value = sma / (endBar - startBar + 1);
        return value;

More information about the R-SIG-Finance mailing list