Question

I would like to use R's quantmod package to test some technical indicators for trading stocks. My goal is to automatically run an indicator over a Stock Symbol and the result tells me what would have been my performance if I would have followed strictly the indicator (e.g. MACD).

The website www.quantmod.com is very interesting, however it seems that the author stopped updating it a few years ago.

What I can do so far: getting stock symbols via the package "quantmod" using the plotting functions and visually interpreting them. e.g. using the MACD one trading signal is when the two lines cross each other.

What I cannot do (but would like to do): - automatically visually indicating the signal (displaying), e.g. with an arrow or any graphical symbol in the plot - the simulation: automatically trade (buy or sell) each time the signal arrives and tells me at the end if this technical indicator is useful for the specific stock or index.

here is some basic code for the plotting:

require(quantmod)
getSymbols("IBM", source="google")
chartSeries(IBM, subset="last 10 weeks", type="candles")
addMACD()

I hope I could explain what I am looking for.

Thanks in advance

Était-ce utile?

La solution

You may want to look at the blotter and the quantstrat packages. A.o. the chart.Posn() function there will provide you with the plot that you are looking for, and includes PL and DD curves as well.

HTH,

Jan Humme.

Autres conseils

There are several pieces to what you're asking. I'll try to answer piece by piece.

automatically visually indicating the signal (displaying), e.g. with an arrow or any graphical symbol in the plot

You can plot symbols with par(new=TRUE); points(.........). Check out ?pch.

the simulation: automatically trade (buy or sell)

It's unclear if you want to simulate trades or actually trade. If the latter then that's another ball of wax to connect to your trading platform. If the former, quantstrat provides a generic infrastructure to model and backtest signal-based quantitative strategies.

each time the signal arrives

Where does your data come from? These are some other wires you need to connect for yourself; it won't be "automatic".

and tells me at the end if this technical indicator is useful

That's something you need to define.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top