Welcome, Guest. Please Login or Register
Algorithmic Trading Forum
  News:
Visit our new bookstore on http://astore.amazon.com/algortradifor-2...
  HomeHelpSearchLoginRegister  
 
Pages: 1
Send Topic Print
Building An Algo (Read 8451 times)
Ron Civil
Newbie
*
Offline

I like this forum!

Posts: 2

Building An Algo
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
Ron
roncivil77@yahoo.com
Back to top
 
 
  IP Logged
Algo Designer
Forum Administrator
*****
Offline

Nihil desperandum

Posts: 182
Sydney
Gender: male
Re: Building An Algo
Reply #1 - 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:

Code:
require(quantmod)

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[is.na(sig)] = 0

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

eq = cumprod(1 + ret * sig)

lineChart(prices)
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:

install.packages("quantmod")

You might find the following high level back testing guide useful:
http://blog.fosstrading.com/2011/03/how-to-backtest-strategy-in-r.html

One more thing! I left one important condition out in the signal generator. Let's see if you can spot it. Smiley
Back to top
 
« Last Edit: 01/25/12 at 14:40:32 by Algo Designer »  

"Success is the sum of small efforts, repeated day in and day out..."
  IP Logged
Ron Civil
Newbie
*
Offline

I like this forum!

Posts: 2

Re: Building An Algo
Reply #2 - 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
Ron
Back to top
 
 
  IP Logged
Algo Designer
Forum Administrator
*****
Offline

Nihil desperandum

Posts: 182
Sydney
Gender: male
Re: Building An Algo
Reply #3 - 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"

Back to top
 
 

"Success is the sum of small efforts, repeated day in and day out..."
  IP Logged
Pages: 1
Send Topic Print