Binary Market Timing based on XLI/XLU for EoM, EoW or EoD traders

Since the release of the previous post regarding TAA strategies, Aurelia and I have been working on the implementation of another market timing filter Kevin McGrath developed on the Stockfetcher forum. By using the XLI and XLU etf pair as proxies for bullishness and bearishness, the allocation strategy is simplified down to a binary process.

This binary process distinguishes only two market states: a bull market and a bear market. Bullishness is considered when the relative strength of XLI is stronger than that of XLU. However when the relative strength of XLU outperforms XLI's, bears are supposed to have the upper hand.

In a bullish state of the market one could just invest in XLI, but also in etf's like IWM or TNA (default in this presentation). For bearish times one chooses defensive instruments like XLU, TLT or TMF (default). One could even pick a cash proxy such as SHY.

In this presentation the strategy proposes to enter TNA in case XLI has the highest RS against XLU on rotationMoment (i.e. the last day of the previous month or of the previous week). Otherwise a position in TMF is the choice to make. The strategy is an "all out, all in" allocation, just like the previously presented ones. 

To accommodate various trading horizons we have adapted the strategy in such a way so it can be used for months, weeks, days and X Days as rotation periods (see rotation mode options below).

WARNING: Beware of violating Regulation T ("free riding") and a subsequent 90-day account freeze in case of cash accounts and frequent rotations. Please consult your broker beforehand! 

To use the strategy i.e. on a chart with 3d bars as shown below, use as rotation mode: ChartPeriod.

For Weekend Traders two rotation modes are suitable: EoW on daily charts or ChartPeriod on weekly charts.

As usual the scripts are available for copy/paste in the comment section.