<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/'><id>tag:blogger.com,1999:blog-5815834906618132494.post5363003943111435813..comments</id><updated>2010-11-18T04:59:35.482-06:00</updated><category term='xts'/><category term='Code'/><category term='Interactive Brokers'/><category term='Drawdown'/><category term='LSPM'/><category term='quantmod'/><category term='Data'/><category term='Releases'/><category term='HIstorical Data'/><category term='blotter'/><category term='quantstrat'/><category term='Events'/><category term='TTR'/><category term='API'/><category term='IBrokers'/><category term='Examples'/><category term='R'/><category term='Excel'/><title type='text'>Comments on FOSS Trading: Testing RSI(2) with R, First Steps</title><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://blog.fosstrading.com/feeds/5363003943111435813/comments/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5815834906618132494/5363003943111435813/comments/default'/><link rel='alternate' type='text/html' href='http://blog.fosstrading.com/2009/04/testing-rsi2-with-r.html'/><author><name>Joshua Ulrich</name><uri>https://profiles.google.com/101580259945483587604</uri><email>noreply@blogger.com</email><gd:image xmlns:gd='http://schemas.google.com/g/2005' rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh4.googleusercontent.com/-cNBfNQ-0tKE/AAAAAAAAAAI/AAAAAAAAAAA/QxKaQjp1h4M/s512-c/photo.jpg'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>14</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-5815834906618132494.post-8153651000303336296</id><published>2010-11-18T04:59:35.482-06:00</published><updated>2010-11-18T04:59:35.482-06:00</updated><title type='text'>Thanks, now its working fine.</title><content type='html'>Thanks, now its working fine.</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5815834906618132494/5363003943111435813/comments/default/8153651000303336296'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5815834906618132494/5363003943111435813/comments/default/8153651000303336296'/><link rel='alternate' type='text/html' href='http://blog.fosstrading.com/2009/04/testing-rsi2-with-r.html?showComment=1290077975482#c8153651000303336296' title=''/><author><name>javier</name><uri>http://www.blogger.com/profile/14317888627251050785</uri><email>noreply@blogger.com</email><gd:image xmlns:gd='http://schemas.google.com/g/2005' rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:in-reply-to xmlns:thr='http://purl.org/syndication/thread/1.0' href='http://blog.fosstrading.com/2009/04/testing-rsi2-with-r.html' ref='tag:blogger.com,1999:blog-5815834906618132494.post-5363003943111435813' source='http://www.blogger.com/feeds/5815834906618132494/posts/default/5363003943111435813' type='text/html'/><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='blogger.itemClass' value='pid-387893073'/></entry><entry><id>tag:blogger.com,1999:blog-5815834906618132494.post-5980615233113694654</id><published>2010-11-09T21:54:05.575-06:00</published><updated>2010-11-09T21:54:05.575-06:00</updated><title type='text'>Hi Javier,

Since I don&amp;#39;t have access to your ...</title><content type='html'>Hi Javier,&lt;br /&gt;&lt;br /&gt;Since I don&amp;#39;t have access to your data, I can only guess what the problem(s) may be.  My guess is that you didn&amp;#39;t read your CSV into R as an xts object.  read.csv() creates a data.frame.  From there, you need to create an xts object, or at least ensure that the rownames of your data.frame contain the dates/times so as.xts can create an xts object.&lt;br /&gt;&lt;br /&gt;HTH,&lt;br /&gt;Josh</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5815834906618132494/5363003943111435813/comments/default/5980615233113694654'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5815834906618132494/5363003943111435813/comments/default/5980615233113694654'/><link rel='alternate' type='text/html' href='http://blog.fosstrading.com/2009/04/testing-rsi2-with-r.html?showComment=1289361245575#c5980615233113694654' title=''/><author><name>Joshua Ulrich</name><uri>http://www.blogger.com/profile/16641971932645230429</uri><email>noreply@blogger.com</email><gd:image xmlns:gd='http://schemas.google.com/g/2005' rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:in-reply-to xmlns:thr='http://purl.org/syndication/thread/1.0' href='http://blog.fosstrading.com/2009/04/testing-rsi2-with-r.html' ref='tag:blogger.com,1999:blog-5815834906618132494.post-5363003943111435813' source='http://www.blogger.com/feeds/5815834906618132494/posts/default/5363003943111435813' type='text/html'/><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='blogger.itemClass' value='pid-1996417509'/></entry><entry><id>tag:blogger.com,1999:blog-5815834906618132494.post-5027063222398288384</id><published>2010-11-08T09:24:22.866-06:00</published><updated>2010-11-08T09:24:22.866-06:00</updated><title type='text'>Hi Josh, 

I am getting the following errors when ...</title><content type='html'>Hi Josh, &lt;br /&gt;&lt;br /&gt;I am getting the following errors when running the code. &lt;br /&gt;I have uploaded the data from a CSV file, and when I plot the chart &amp;quot;Michael&amp;#39;s nice chart&amp;quot; the dates do not show in the chart, instead I get a series running from 0 to 3000. &lt;br /&gt;Also if I try to add the total equity line, I get the following error message&lt;br /&gt;&lt;br /&gt;&amp;quot;Error en addTA(eq_all) : &lt;br /&gt;  non-xtsible data must match the length of the underlying series&amp;quot;&lt;br /&gt;&lt;br /&gt;Do you know where the error comes from and how I could fix it?&lt;br /&gt;&lt;br /&gt;Thank you very much</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5815834906618132494/5363003943111435813/comments/default/5027063222398288384'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5815834906618132494/5363003943111435813/comments/default/5027063222398288384'/><link rel='alternate' type='text/html' href='http://blog.fosstrading.com/2009/04/testing-rsi2-with-r.html?showComment=1289229862866#c5027063222398288384' title=''/><author><name>javier</name><uri>http://www.blogger.com/profile/14317888627251050785</uri><email>noreply@blogger.com</email><gd:image xmlns:gd='http://schemas.google.com/g/2005' rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:in-reply-to xmlns:thr='http://purl.org/syndication/thread/1.0' href='http://blog.fosstrading.com/2009/04/testing-rsi2-with-r.html' ref='tag:blogger.com,1999:blog-5815834906618132494.post-5363003943111435813' source='http://www.blogger.com/feeds/5815834906618132494/posts/default/5363003943111435813' type='text/html'/><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='blogger.itemClass' value='pid-387893073'/></entry><entry><id>tag:blogger.com,1999:blog-5815834906618132494.post-4983429442009734107</id><published>2010-03-06T18:53:59.495-06:00</published><updated>2010-03-06T18:53:59.495-06:00</updated><title type='text'>Intelligent Trading,

The short sales were flipped...</title><content type='html'>Intelligent Trading,&lt;br /&gt;&lt;br /&gt;The short sales were flipped only to replicate the chart.  Notice the eq_all object does not use the flipped short sales.  Thanks for the code to plot all thee series.</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5815834906618132494/5363003943111435813/comments/default/4983429442009734107'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5815834906618132494/5363003943111435813/comments/default/4983429442009734107'/><link rel='alternate' type='text/html' href='http://blog.fosstrading.com/2009/04/testing-rsi2-with-r.html?showComment=1267923239495#c4983429442009734107' title=''/><author><name>Joshua Ulrich</name><uri>http://www.blogger.com/profile/16641971932645230429</uri><email>noreply@blogger.com</email><gd:image xmlns:gd='http://schemas.google.com/g/2005' rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:in-reply-to xmlns:thr='http://purl.org/syndication/thread/1.0' href='http://blog.fosstrading.com/2009/04/testing-rsi2-with-r.html' ref='tag:blogger.com,1999:blog-5815834906618132494.post-5363003943111435813' source='http://www.blogger.com/feeds/5815834906618132494/posts/default/5363003943111435813' type='text/html'/><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='blogger.itemClass' value='pid-1996417509'/></entry><entry><id>tag:blogger.com,1999:blog-5815834906618132494.post-5581009276082213999</id><published>2010-03-01T23:01:20.203-06:00</published><updated>2010-03-01T23:01:20.203-06:00</updated><title type='text'>Hello and thanks for sharing your work.  I was loo...</title><content type='html'>Hello and thanks for sharing your work.  I was looking over this issue with flipping the short sales upsidown.  It seems to me that using your methodology, shows that the short sales were net positive, in which case the total short return would be net pos. Have you contacted the original author to ask why his short return curve was net negative (It seems he intended that as his average short daily results shows a negative value)? It is very important to decide one way or the other as the results will be completely backwards and obviously only one method is the correct one.&lt;br /&gt;&lt;br /&gt;The following would seem to adjust all the values back to the way you intended.&lt;br /&gt;&lt;br /&gt;sigdn[is.na(sigdn)] &amp;lt;- -1&lt;br /&gt;eq_dn &amp;lt;- cumprod(1+ret*sigdn)&lt;br /&gt;&lt;br /&gt;plot.zoo( cbind(eq_up, eq_dn,eq_all),&lt;br /&gt;ylab=c(&amp;quot;Long&amp;quot;,&amp;quot;Short&amp;quot;,&amp;quot;Combined&amp;quot;), col=c(&amp;quot;green&amp;quot;,&amp;quot;red&amp;quot;,&amp;quot;blue&amp;quot;),&lt;br /&gt;main=&amp;quot;Simple RSI(2) Strategy: 2000-01-02 through 2008-12-07&amp;quot; )&lt;br /&gt;&lt;br /&gt;Also, the plot would be useful to show all three curves.&lt;br /&gt;&lt;br /&gt;Look forward to going through more of your blog.&lt;br /&gt;-----------------------------------&lt;br /&gt;http://intelligenttradingtech.blogspot.com/</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5815834906618132494/5363003943111435813/comments/default/5581009276082213999'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5815834906618132494/5363003943111435813/comments/default/5581009276082213999'/><link rel='alternate' type='text/html' href='http://blog.fosstrading.com/2009/04/testing-rsi2-with-r.html?showComment=1267506080203#c5581009276082213999' title=''/><author><name>Intelligent Trading</name><uri>http://www.blogger.com/profile/17765336450326139518</uri><email>noreply@blogger.com</email><gd:image xmlns:gd='http://schemas.google.com/g/2005' rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:in-reply-to xmlns:thr='http://purl.org/syndication/thread/1.0' href='http://blog.fosstrading.com/2009/04/testing-rsi2-with-r.html' ref='tag:blogger.com,1999:blog-5815834906618132494.post-5363003943111435813' source='http://www.blogger.com/feeds/5815834906618132494/posts/default/5363003943111435813' type='text/html'/><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='blogger.itemClass' value='pid-155885412'/></entry><entry><id>tag:blogger.com,1999:blog-5815834906618132494.post-506547771464007955</id><published>2009-04-26T21:45:00.000-05:00</published><updated>2009-04-26T21:45:00.000-05:00</updated><title type='text'>jt,

You're welcome.  I hope to post the follow-up...</title><content type='html'>jt,&lt;br /&gt;&lt;br /&gt;You're welcome.  I hope to post the follow-up in a few days.  I just got back from the R/Finance 2009 conference in Chicago (I will be posting about that as well).&lt;br /&gt;&lt;br /&gt;Please ensure you're using the latest versions of TTR and quantmod from CRAN and the code I updated to fix Toby's issue.  Also, please double-check your results - because 'rsi' (with the arguments I used) and 'GSPC' should never have different lengths.&lt;br /&gt;&lt;br /&gt;You're correct, 'eq_all' represents the strategy's total cumulative return.  Taking the absolute value of 'sig' before calculating 'eq_all' would convert all the short signals to long signals.  Note that I multiplied by -1 when calculating 'eq_dn' in order to make the equity curve trend downward like Michael's graph.</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5815834906618132494/5363003943111435813/comments/default/506547771464007955'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5815834906618132494/5363003943111435813/comments/default/506547771464007955'/><link rel='alternate' type='text/html' href='http://blog.fosstrading.com/2009/04/testing-rsi2-with-r.html?showComment=1240800300000#c506547771464007955' title=''/><author><name>Josh Ulrich</name><uri>http://www.blogger.com/profile/16641971932645230429</uri><email>noreply@blogger.com</email><gd:image xmlns:gd='http://schemas.google.com/g/2005' rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:in-reply-to xmlns:thr='http://purl.org/syndication/thread/1.0' href='http://blog.fosstrading.com/2009/04/testing-rsi2-with-r.html' ref='tag:blogger.com,1999:blog-5815834906618132494.post-5363003943111435813' source='http://www.blogger.com/feeds/5815834906618132494/posts/default/5363003943111435813' type='text/html'/><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='blogger.itemClass' value='pid-1996417509'/></entry><entry><id>tag:blogger.com,1999:blog-5815834906618132494.post-5964822640465007505</id><published>2009-04-25T13:39:00.000-05:00</published><updated>2009-04-25T13:39:00.000-05:00</updated><title type='text'>Josh,

Thanks for your blog, and especially this p...</title><content type='html'>Josh,&lt;br /&gt;&lt;br /&gt;Thanks for your blog, and especially this post.  I eagerly await your followup.&lt;br /&gt;&lt;br /&gt;I've also been having some similar problems as Toby.  Going back and working through it line by line, my first observation is that the length of rsi, and therefore sigup, sigdn and sig is 1 element longer than Cl(GSPC).    This is partially what causes the warnings in the calculation of eq_up, eq_dn, and eq_all.  It's also what causes the failure of the addTA(eq_all) line.  At least, that's the best I can figure.&lt;br /&gt;&lt;br /&gt;I was wondering about the calculation of eq_all, what is it supposed to represent?  If it's supposed to represent the cumulative return from both the long and short strategy, should you be taking the absolute value of sig?&lt;br /&gt;&lt;br /&gt;Again, thanks so much for the post.  It really helps to be able to learn from real examples.</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5815834906618132494/5363003943111435813/comments/default/5964822640465007505'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5815834906618132494/5363003943111435813/comments/default/5964822640465007505'/><link rel='alternate' type='text/html' href='http://blog.fosstrading.com/2009/04/testing-rsi2-with-r.html?showComment=1240684740000#c5964822640465007505' title=''/><author><name>jt</name><uri>http://www.blogger.com/profile/12551175212607761356</uri><email>noreply@blogger.com</email><gd:image xmlns:gd='http://schemas.google.com/g/2005' rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:in-reply-to xmlns:thr='http://purl.org/syndication/thread/1.0' href='http://blog.fosstrading.com/2009/04/testing-rsi2-with-r.html' ref='tag:blogger.com,1999:blog-5815834906618132494.post-5363003943111435813' source='http://www.blogger.com/feeds/5815834906618132494/posts/default/5363003943111435813' type='text/html'/><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='blogger.itemClass' value='pid-1533572936'/></entry><entry><id>tag:blogger.com,1999:blog-5815834906618132494.post-2123183574436128895</id><published>2009-04-19T16:07:00.000-05:00</published><updated>2009-04-19T16:07:00.000-05:00</updated><title type='text'>Josh, thanks for that - clears things up for me! A...</title><content type='html'>Josh, thanks for that - clears things up for me! Again, a very useful example code. Thanks for posting.</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5815834906618132494/5363003943111435813/comments/default/2123183574436128895'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5815834906618132494/5363003943111435813/comments/default/2123183574436128895'/><link rel='alternate' type='text/html' href='http://blog.fosstrading.com/2009/04/testing-rsi2-with-r.html?showComment=1240175220000#c2123183574436128895' title=''/><author><name>Toby</name><uri>http://www.blogger.com/profile/14836951237109349355</uri><email>noreply@blogger.com</email><gd:image xmlns:gd='http://schemas.google.com/g/2005' rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:in-reply-to xmlns:thr='http://purl.org/syndication/thread/1.0' href='http://blog.fosstrading.com/2009/04/testing-rsi2-with-r.html' ref='tag:blogger.com,1999:blog-5815834906618132494.post-5363003943111435813' source='http://www.blogger.com/feeds/5815834906618132494/posts/default/5363003943111435813' type='text/html'/><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='blogger.itemClass' value='pid-1056576446'/></entry><entry><id>tag:blogger.com,1999:blog-5815834906618132494.post-8330766580143959582</id><published>2009-04-18T20:55:00.000-05:00</published><updated>2009-04-18T20:55:00.000-05:00</updated><title type='text'>Damian,

If I understand correctly, that should be...</title><content type='html'>Damian,&lt;br /&gt;&lt;br /&gt;If I understand correctly, that should be as easy as running the code I posted each day... but removing the "from=" argument from getSymbols() and looking at today's "sig" value.  Does that answer your question?&lt;br /&gt;&lt;br /&gt;Toby,&lt;br /&gt;&lt;br /&gt;Thanks for the comment.  My guess is that the error is caused by the Lag() function.  I intended to use quantmod:::Lag(), but if you attached - via library() - another package with a Lag() function before you attached quantmod, the first package's Lag() function would be used.  I will edit the code in the post to be more robust.  Thank you!</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5815834906618132494/5363003943111435813/comments/default/8330766580143959582'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5815834906618132494/5363003943111435813/comments/default/8330766580143959582'/><link rel='alternate' type='text/html' href='http://blog.fosstrading.com/2009/04/testing-rsi2-with-r.html?showComment=1240106100000#c8330766580143959582' title=''/><author><name>Josh Ulrich</name><uri>http://www.blogger.com/profile/16641971932645230429</uri><email>noreply@blogger.com</email><gd:image xmlns:gd='http://schemas.google.com/g/2005' rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:in-reply-to xmlns:thr='http://purl.org/syndication/thread/1.0' href='http://blog.fosstrading.com/2009/04/testing-rsi2-with-r.html' ref='tag:blogger.com,1999:blog-5815834906618132494.post-5363003943111435813' source='http://www.blogger.com/feeds/5815834906618132494/posts/default/5363003943111435813' type='text/html'/><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='blogger.itemClass' value='pid-1996417509'/></entry><entry><id>tag:blogger.com,1999:blog-5815834906618132494.post-4858112902255911922</id><published>2009-04-18T12:05:00.000-05:00</published><updated>2009-04-18T12:05:00.000-05:00</updated><title type='text'>A very interesting post and a great example of usi...</title><content type='html'>A very interesting post and a great example of using R in the context of evaluating a trading strategy.&lt;br /&gt;&lt;br /&gt;When I first ran the code I got the error at the bottom of this post. However, if I lop of the first row of the signals vectors (e.g. with tail(sigup, -1)) I get the results you posted.&lt;br /&gt;&lt;br /&gt;I am very new to R; does this make sense to you?&lt;br /&gt;&lt;br /&gt;&lt;I&gt;Error in addTA(eq_all) : &lt;br /&gt;  non-xtsible data must match the length of the underlying series&lt;br /&gt;In addition: Warning messages:&lt;br /&gt;1: In ret * sigup :&lt;br /&gt;  longer object length is not a multiple of shorter object length&lt;br /&gt;2: In ret * sigdn :&lt;br /&gt;  longer object length is not a multiple of shorter object length&lt;br /&gt;3: In ret * sig :&lt;br /&gt;  longer object length is not a multiple of shorter object length&lt;/I&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5815834906618132494/5363003943111435813/comments/default/4858112902255911922'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5815834906618132494/5363003943111435813/comments/default/4858112902255911922'/><link rel='alternate' type='text/html' href='http://blog.fosstrading.com/2009/04/testing-rsi2-with-r.html?showComment=1240074300000#c4858112902255911922' title=''/><author><name>Toby</name><uri>http://www.blogger.com/profile/14836951237109349355</uri><email>noreply@blogger.com</email><gd:image xmlns:gd='http://schemas.google.com/g/2005' rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:in-reply-to xmlns:thr='http://purl.org/syndication/thread/1.0' href='http://blog.fosstrading.com/2009/04/testing-rsi2-with-r.html' ref='tag:blogger.com,1999:blog-5815834906618132494.post-5363003943111435813' source='http://www.blogger.com/feeds/5815834906618132494/posts/default/5363003943111435813' type='text/html'/><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='blogger.itemClass' value='pid-1056576446'/></entry><entry><id>tag:blogger.com,1999:blog-5815834906618132494.post-6626970165058024906</id><published>2009-04-18T09:28:00.000-05:00</published><updated>2009-04-18T09:28:00.000-05:00</updated><title type='text'>Sure - when you're running a complex system, you n...</title><content type='html'>Sure - when you're running a complex system, you need a way to scan the market on an ongoing basis to find opportunities.  So, I want to scan EOD today for entries tomorrow.  Make sense?</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5815834906618132494/5363003943111435813/comments/default/6626970165058024906'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5815834906618132494/5363003943111435813/comments/default/6626970165058024906'/><link rel='alternate' type='text/html' href='http://blog.fosstrading.com/2009/04/testing-rsi2-with-r.html?showComment=1240064880000#c6626970165058024906' title=''/><author><name>Damian</name><uri>http://www.blogger.com/profile/16016686632386396090</uri><email>noreply@blogger.com</email><gd:image xmlns:gd='http://schemas.google.com/g/2005' rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:in-reply-to xmlns:thr='http://purl.org/syndication/thread/1.0' href='http://blog.fosstrading.com/2009/04/testing-rsi2-with-r.html' ref='tag:blogger.com,1999:blog-5815834906618132494.post-5363003943111435813' source='http://www.blogger.com/feeds/5815834906618132494/posts/default/5363003943111435813' type='text/html'/><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='blogger.itemClass' value='pid-1750744102'/></entry><entry><id>tag:blogger.com,1999:blog-5815834906618132494.post-2284358577935620145</id><published>2009-04-17T14:31:00.000-05:00</published><updated>2009-04-17T14:31:00.000-05:00</updated><title type='text'>Damian,

Awesome questions!  They really highlight...</title><content type='html'>Damian,&lt;br /&gt;&lt;br /&gt;Awesome questions!  They really highlight how much I take for granted as a long-time R user...&lt;br /&gt;&lt;br /&gt;&amp;quot;^GSPC&amp;quot; is the Yahoo Finance ticker symbol, but R objects can only start with a letter (or a &amp;quot;.&amp;quot; followed by a non-number), so getSymbols() converts &amp;quot;^GSPC&amp;quot; to &amp;quot;GSPC&amp;quot;.&lt;br /&gt;&lt;br /&gt;If the data are in a CSV file, you can still use the getSymbols() function, but it would look something like:&lt;br /&gt;getSymbols(&amp;quot;GSPC&amp;quot;, src=&amp;quot;csv&amp;quot;)&lt;br /&gt;This assumes there&amp;#39;s a file named &amp;quot;GSPC.csv&amp;quot; in your current working directory (see functions getwd() and setwd()).  getSymbols() has ways to deal with other file types as well...&lt;br /&gt;&lt;br /&gt;Since I&amp;#39;m using close-to-close returns, I&amp;#39;m assuming you transact on the close price.  This is why I align the signals generated with today&amp;#39;s data with tomorrow&amp;#39;s returns.  E.g. if today&amp;#39;s data gives me a long signal, I&amp;#39;ll buy at the close and hold until tomorrow&amp;#39;s close.  Great questions!&lt;br /&gt;&lt;br /&gt;There are missing values in my signals because the first two RSI(2) values are missing, and the lag creates another missing value.  If I did not replace the missing values with zero, it would cause the result of the cumprod() function to be a vector of missing values (a missing value added, subtracted, multiplied, or divided by anything produces a missing value).&lt;br /&gt;&lt;br /&gt;I did not show the chart created by:&lt;br /&gt;chartSeries(GSPC, type=&amp;quot;line&amp;quot;)&lt;br /&gt;I was hoping you would see it when you copy/paste the code into your own R session. :)  And yes, it compares the strategy results with the S&amp;amp;P.&lt;br /&gt;&lt;br /&gt;Future posts will show how to work with a basket of stocks and multiple strategies.  It&amp;#39;s good to know that I&amp;#39;ve planned to address something of interest.&lt;br /&gt;&lt;br /&gt;I&amp;#39;m not sure what you mean about producing a scan of stocks as you go forward in time.  Could you clarify?</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5815834906618132494/5363003943111435813/comments/default/2284358577935620145'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5815834906618132494/5363003943111435813/comments/default/2284358577935620145'/><link rel='alternate' type='text/html' href='http://blog.fosstrading.com/2009/04/testing-rsi2-with-r.html?showComment=1239996660000#c2284358577935620145' title=''/><author><name>Josh Ulrich</name><uri>http://www.blogger.com/profile/16641971932645230429</uri><email>noreply@blogger.com</email><gd:image xmlns:gd='http://schemas.google.com/g/2005' rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:in-reply-to xmlns:thr='http://purl.org/syndication/thread/1.0' href='http://blog.fosstrading.com/2009/04/testing-rsi2-with-r.html' ref='tag:blogger.com,1999:blog-5815834906618132494.post-5363003943111435813' source='http://www.blogger.com/feeds/5815834906618132494/posts/default/5363003943111435813' type='text/html'/><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='blogger.itemClass' value='pid-1996417509'/></entry><entry><id>tag:blogger.com,1999:blog-5815834906618132494.post-3780458333672900921</id><published>2009-04-16T19:15:00.000-05:00</published><updated>2009-04-16T19:15:00.000-05:00</updated><title type='text'>Thanks for this great post.  It was helpful to see...</title><content type='html'>Thanks for this great post.  It was helpful to see how to pull the tools together.</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5815834906618132494/5363003943111435813/comments/default/3780458333672900921'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5815834906618132494/5363003943111435813/comments/default/3780458333672900921'/><link rel='alternate' type='text/html' href='http://blog.fosstrading.com/2009/04/testing-rsi2-with-r.html?showComment=1239927300000#c3780458333672900921' title=''/><author><name>Bill</name><uri>http://www.blogger.com/profile/15482491081305577455</uri><email>noreply@blogger.com</email><gd:image xmlns:gd='http://schemas.google.com/g/2005' rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:in-reply-to xmlns:thr='http://purl.org/syndication/thread/1.0' href='http://blog.fosstrading.com/2009/04/testing-rsi2-with-r.html' ref='tag:blogger.com,1999:blog-5815834906618132494.post-5363003943111435813' source='http://www.blogger.com/feeds/5815834906618132494/posts/default/5363003943111435813' type='text/html'/><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='blogger.itemClass' value='pid-513820783'/></entry><entry><id>tag:blogger.com,1999:blog-5815834906618132494.post-1593226984846735557</id><published>2009-04-15T07:42:00.000-05:00</published><updated>2009-04-15T07:42:00.000-05:00</updated><title type='text'>Really cool.  A lot of questions:

&amp;quot;# Calcula...</title><content type='html'>Really cool.  A lot of questions:&lt;br /&gt;&lt;br /&gt;&amp;quot;# Calculate the RSI indicator&lt;br /&gt;rsi &amp;lt;- RSI(Cl(GSPC),2)&amp;quot;&lt;br /&gt;&lt;br /&gt;When you reference the symbol for getting the data, you referenced it via &amp;quot;^GSPC&amp;quot; - how did it get assigned to GSPC?&lt;br /&gt;&lt;br /&gt;Secondly, if I have the data stored locally, how would I reference it?&lt;br /&gt;&lt;br /&gt;&amp;quot;# Lag signals to align with days in market,&lt;br /&gt;# not days signals were generated&lt;br /&gt;sigup &amp;lt;- Lag(sigup)&lt;br /&gt;sigdn &amp;lt;- Lag(sigdn)&amp;quot;&lt;br /&gt;&lt;br /&gt;Why did you do this?  Is this to buy/sell on the next day rather than current day the signal is generated?&lt;br /&gt;&lt;br /&gt;How do you know if you buying/selling on the open or close?&lt;br /&gt;&lt;br /&gt;&amp;quot;# Replace missing signals with no position&lt;br /&gt;# (generally just at beginning of series)&lt;br /&gt;sigup[is.na(sigup)] &amp;lt;- 0&lt;br /&gt;sigdn[is.na(sigdn)] &amp;lt;- 0&amp;quot;&lt;br /&gt;&lt;br /&gt;This I don&amp;#39;t understand at all....&lt;br /&gt;&lt;br /&gt;&amp;quot;# Calculate Close-to-Close returns&lt;br /&gt;ret &amp;lt;- ROC(Cl(GSPC))&lt;br /&gt;ret[1] &amp;lt;- 0&amp;quot;&lt;br /&gt;&lt;br /&gt;I&amp;#39;m guessing this is for the S&amp;amp;P comparison?&lt;br /&gt;&lt;br /&gt;&amp;quot;# Create a chart showing the S&amp;amp;P500&lt;br /&gt;chartSeries(GSPC, type=&amp;quot;line&amp;quot;)&amp;quot;&lt;br /&gt;&lt;br /&gt;Did you not show this chart?&lt;br /&gt;&lt;br /&gt;If you were working with a group of stocks:&lt;br /&gt;&lt;br /&gt;- How would you work across a basket of stocks?&lt;br /&gt;- Is it possible to produce a scan of those stock to show which ones meet the buy criteria when they are not backtested (meaning, as you go forward in time)?&lt;br /&gt;&lt;br /&gt;Very cool stuff - sorry for all the questions.</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5815834906618132494/5363003943111435813/comments/default/1593226984846735557'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5815834906618132494/5363003943111435813/comments/default/1593226984846735557'/><link rel='alternate' type='text/html' href='http://blog.fosstrading.com/2009/04/testing-rsi2-with-r.html?showComment=1239799320000#c1593226984846735557' title=''/><author><name>Damian</name><uri>http://www.blogger.com/profile/16016686632386396090</uri><email>noreply@blogger.com</email><gd:image xmlns:gd='http://schemas.google.com/g/2005' rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:in-reply-to xmlns:thr='http://purl.org/syndication/thread/1.0' href='http://blog.fosstrading.com/2009/04/testing-rsi2-with-r.html' ref='tag:blogger.com,1999:blog-5815834906618132494.post-5363003943111435813' source='http://www.blogger.com/feeds/5815834906618132494/posts/default/5363003943111435813' type='text/html'/><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='blogger.itemClass' value='pid-1750744102'/></entry></feed>
