Code

Tactical asset allocation using blotter

NOTE: If you simply want to test strategies in R, please see the post: Tactical Asset Allocation Using quantstrat. quantstrat uses blotter behind the scenes, but provides a higher level of abstraction. blotter is an R package that tracks the P&L of your trading systems (or simulations), even if your portfolio spans many security types and/or currencies. This post uses blotter to track a simple two-ETF trading system. The contents of this post borrow heavily from code and comments in the “longtrend” demo script in the blotter package.

David Varadi's RSI(2) alternative

hello josh, If I want to sell the stock when the R… Bear - Jul 4, 2009hello josh, If I want to sell the stock when the RSI retereat from the 90 or buy it when the RSI above 10 again how can I modify the code? Hi Bear, You need to use a lagged value of RSI in addition to the current value. The code below shows how to do it.

David Varadi's RSI(2) alternative

Here’s a quick R implementation of David Varadi’s alternative to the RSI(2). Michael Stokes over at the MarketSci blog has three great posts exploring this indicator: [Varadi’s RSI(2) Alternative: The DV(2)](http://marketsci.wordpress.com/2009/07/15/varadi%e2%80%99s-rsi2-alternative-the-dv2/ “Permanent Link to “Varadi’s RSI(2) Alternative: The DV(2)"") [RSI(2) vs. DV(2)](http://marketsci.wordpress.com/2009/07/16/rsi2-vs-dv2/ “Permanent Link to “RSI(2) vs. DV(2)"") [Last Couple of Notes on DV(2)](http://marketsci.wordpress.com/2009/07/17/last-couple-of-notes-on-dv2/ “Permanent Link to “Last Couple of Notes on DV(2)"") Here’s the R code:  DV <- function(HLC, n=2, bounded=FALSE) {

RSI(2) Evaluation

I have run this script to see how RIS2 with scalin… White Cube - Apr 6, 2012I have run this script to see how RIS2 with scaling has performed since 2009. On the long side the performance has not been as good as before (with some sharp drawdowns). On the short side the equity curve went down for 2 years and seems picking up again since 2011. Has the magic RSI gone ?

RSI(2) Evaluation

This post continues the series of investigating the RSI(2) strategy. The first post replicated this simple RSI(2) strategy from the MarketSci Blog using R. The second post showed how to replicate the strategy that scales in/out of RSI(2). If you like the RSI(2), be sure to check out David Varadi’s RSI(2) alternative! This post will use the PerformanceAnalytics package to evaluate the rules that scale in/out of positions. I’ve also provided a simple function that provides some summary statistics.

RSI(2) with Position Sizing

i look forward to it – never could get my head ar… Autore del blog - May 0, 2009i look forward to it – never could get my head around performance metrics.. This is awesome - very cool. I also was curious if you could put together a simple example of the following: - Take four ETFs (SPY,IWM,QQQQ,TLT) and rank them by their 12m ROC. - Buy the top one on the first day of the month.

RSI(2) with Position Sizing

Though it’s more than two weeks later, here’s the second post in the series that will demonstrate how to build, test, and implement a trading strategy with R. You can find the first post here. The first post replicated this simple RSI(2) strategy from the MarketSci Blog. This second post will demonstrate how to replicate this strategy that scales in/out of RSI(2). A couple notes before moving to the code:

Testing RSI(2) with R, First Steps

Really cool. A lot of questions: “# Calcula… Damian - Apr 3, 2009Really cool. A lot of questions: “# Calculate the RSI indicator rsi <- RSI(Cl(GSPC),2)” When you reference the symbol for getting the data, you referenced it via “^GSPC” - how did it get assigned to GSPC? Secondly, if I have the data stored locally, how would I reference it? “# Lag signals to align with days in market,

Testing RSI(2) with R, First Steps

This is the first of a series of posts that will demonstrate how to build, test, and implement a trading strategy using my favorite FOSS, R. I chose the RSI(2) strategy because it has gotten considerable attention on trading blogs over the past 6 months. In particular, I will be replicating and extending some of the results from Michael Stokes’ excellent MarketSci Blog. This post will focus on replicating this simple RSI(2) strategy.