How can I code this rule?

Trying to find a way to code the following rule, for an ETF Sim. I have a list of 3 fixed ETFs (ABC, DEF, GHI) and I want to buy the ETF that had the highest return in the last 30 days.

I tried creating custom Universe or coding straight in the sim rule, but I’m having issues calculating the return of a specific ETF to meet the goal above.

Can anyone share any ideas?

Thanks!!

My mind is about done for the day, but you may want to look up FOrder in the rules reference. Perhaps an FOrder rule that sues the 30-day return as the formula and requires FOrde to be equal to 1, something like that. If this doesn’t get you going, and if nobody else chimes in, I’ll look back tomorrow.

Thanks Marc, but I’m not sure if I got this right. Backtests look horrible :slight_smile: Is this correct?

One rule has a list of the ETFs:
Ticker(“ABC,DEF,GHI”)

The other rule attempts to retrieve the ETF from this list with the highest return in the last 30 days, provided it’s a positive return for that ETF:
FOrder(“100* (Close(0)-Close(30))/Close(30)”,#All,#Desc,true) & FOrder(“100* (Close(0)-Close(30))/Close(30) > 0”,#All,#Desc,true)

I’m trying to validate a white paper I read on the net, and the results are way different.

Thanks!

Your rule won’t work, because #All orders all ETFs in the universe, not only your three identified via “Ticker”.

Several options how to proceed:

  1. If you want to do a simulation, you could create a custom universe with your three ETFs.
  2. Much easier is a quick ETF screener. User Ticker(“SPY, IWM, TLT”) as your only rule, and create a quick ranking as shown below.

For the ETF screen, you will also need to set “Max. No. ETFs (0 for all)” to 1.

Walter

Thanks, folks. Cyberjoe, the screen looks good because the model is long all positions all the time. Setting max to 1 as Walter suggested has a much worse result.

I was trying to replicate the strategy tested on this site, but results are drastically different:
http://volatilitymadesimple.com/a-momentum-rotation-strategy-for-trading-vix-etps/

Perhaps that needs to be rebalanced daily, and not weekly?

Here’s my quick swag at the model. Modify as you see fit.

Easy Volatility Investing

Best,
Walter

Rommelb,

Sorry - I shouldn’t have created that screener without drinking my morning coffee first. Indeed, the number of investments must be specified.

With regard to your undertaking …

(1) The developer of this strategy used the zero cost/slippage assumption. P123 screener backtests usually use 0.25% slippage per trade. You can change this setting and check the impact.

(2) The developer also added the “grim reaper symbol” to the optimized parameter k = 83. Please see his paper: http://papers.ssrn.com/sol3/papers.cfm?abstract_id=2255327 Just experiment by changing that number a little in your screener backtest and you’ll arrive at wildly different returns.

(3) Volatility ETFs have been around since 2010 / 2011. Several people have calculated the hypothetical returns from 2004 through 2010, but their numbers are inconsistent.

(4) Many volatility strategies, even those published in papers, are good examples of curve-fitting. Researchers get carried away and overfit their strategies, by not only modeling the “pattern”, but also the “noise” of the time series. This is how they get to astronomical returns of 100% p.a. with drawdowns in line with those of the S&P500. Out-of-sample, the “noise” is different, and the OOS return has nothing in common with the in-sample return - and, in the worst case, is negative. There is a blogger who was able to outperform the paper’s Volatility Risk Premium strategy (#4) and achieved a 100x higher total equity number… Needless to say that he has not made any money since then.

I think it is very hard to develop a successful volatility ETF strategy. The obvious options are buy-and-hold XIV or short VXX with a small percentage (<5%) of your capital. If you can stomach the volatility of these instruments and are prepared to take huge losses and hope for better returns in the future … For example, the VXX increased by about 500% in Sep/Oct 2008, and the XIV dropped by about 80% over that period.

If you want that in a single rule line without modifying the universe otherwise, try this:

TotalReturn4W=Max((TotalReturn4W*Ticker("ABC")),(TotalReturn4W*Ticker("DEF")),(TotalReturn4W*Ticker("GHI"))) and Ticker("ABC,DEF,GHI")

Thanks CyberJoe, I was suspicious of their posted performance and hence wanted to validate it. I agree with you and I believe these volaility products are better suited for day-trading - or as you said - long-term XIV if willing to stomach the wild swings.

Thanks, Pdemartino, I’ll play with those rules.

The biggest benefit to me was about learning even more about how to further use this great platform.

Thanks!