During this week I have written a crude but seemingly effective systemic risk indicator in R. I decided to share the code for anyone who might be interested.
backtest[z > 0.00015] = 0
Basically the idea is to get the avg pairwise covariance of daily returns for a basket of broad risk assets, and while the value is below a threshold trade a momentum system or similar, and then hedge out or short when the value is above the threshold.
Here is a picture of a crappy plot which I attempted, since I'm not very good at plotting equity curves in R yet (i.e. the below is not an equity curve). Values of 0 indicate hedged (i.e. systemic risk is occurring) and all other values are invested in IWB (Russell 1000 ETF).