Algorithmic Trading Group Forum
General Category >> New to this forum? Join us now! >> Building An Algo

Message started by Ron Civil on 01/23/12 at 19:36:47

Title: Building An Algo
Post by Ron Civil on 01/23/12 at 19:36:47

Hello Algo Trading Group,

I am a trader have been interested in developing some of my strategies into algo's... I have no programming skills and was wondering if someone can give me some direction on how to get started... I have been learning "R" software and was hoping to build algo's with the "R" software.

Any advice would be appreciated

Thank You

Title: Re: Building An Algo
Post by Algo Designer on 01/25/12 at 12:49:52

Thank you for joining the forum, Ron.

Programming is a lot of fun. Delegating the whole trading process to a machine is an interesting intellectual challenge that requires a great deal of patience and a lot of hard work.

You mentioned that you do not have programming skills. If you want to have full control over the strategy development process, it's worth acquiring them. R is a fantastic platform and a reasonably friendly language. You have made a good choice. You might like to pick up one of the "classical" languages (e.g. C, Java) to become more comfortable with programming.

Here is an oversimplified version of a trading model you could play with:


symbol = "^GSPC"

start = "2001-01-01"
end = "2011-12-31"

prices = getSymbols(symbol, from = start, to = end, auto.assign = FALSE)

fastLen = 15
slowLen = 300

close = prices[,6]

fastMA = SMA(close, n = fastLen)
slowMA = SMA(close, n = slowLen)

sig = 0;
sig = ifelse(fastMA > slowMA, 1, -1)
sig = lag(sig, 1)
sig[] = 0

ret = ROC(close, type="discrete")
ret[1] = 0

eq = cumprod(1 + ret * sig)

addSMA(fastLen, col = "blue")
addSMA(slowLen, col = "red")
addTA(eq, col = "cyan")

If you have not installed quantmod package yet, you can do so by running the following command:


You might find the following high level back testing guide useful:

One more thing! I left one important condition out in the signal generator. Let's see if you can spot it. :-)

Title: Re: Building An Algo
Post by Ron Civil on 02/06/12 at 13:00:01

Hi Nihil

Thank You for taking the time to answer my post.

I looked over the code and the missing signal generator is the source for where to get the symbol from?

I am also not sure what the 6 represents in the close= prices[,6]

Excited to learn "R" and thank you for the blog and web link.

Thank You

Title: Re: Building An Algo
Post by Algo Designer on 04/09/12 at 14:47:01

Hi Ron,

"Nihil desperandum" is just a motto in Latin. My name is Vlad.

6 is the number of the adjusted price column (i.e. close price adjusted for corporate actions).

colname(prices) will provide you the list of column names in the prices data frame:

[1] "GSPC.Open"     "GSPC.High"     "GSPC.Low"      "GSPC.Close"    "GSPC.Volume"  
[6] "GSPC.Adjusted"

Algorithmic Trading Group Forum » Powered by YaBB 2.2.2!
YaBB © 2000-2008. All Rights Reserved.