The system will either be long the SP500 or be in cash.
Each month it will look at the short and long term correlations and if stocks/bonds tend to be more correlated than usual, it buys the SP500. If not, it sells it and holds cash.
I will be using yahoo free data: ^GSPC (S&P500 Index) data as the "risk" asset and (1/ ^TNX, the reverse of the 10-year Treasury Yield) to represent long-bonds.
We 'll keep 2 parameters optimizable and lock the long moving average period to 600, to keep things simple.
a. CorelationPeriod (default=90)
b. MAshortPeriod (default=60)
The above graph is using params [90,60]
Just for fun let's do the exact opposite: We will buy when the short term correlation is less than the long term one. Same parameters.
Let us optimize the parameters to get a better sense of what is happening. Is there a "general acceptable area"?
params: [10-->300 10-->300]
There seems to be a "better" area of settings than the one we are using.
Let's try the backtest with params [40 220]. In other words we are calculating correlation using a 2-month window. We are then comparing the almost yearly moving average of that to the 600-day longer term one.
Using these optimized parameters, what would trading the 5 core etfs would look like? Risk on means buy SPY,EEM,EFA and VNQ. Risk off means buy IEF.
The equity is for the whole 5 -asset system. The lower pane shows the Emerging Markets time series (NYSEARCA:EEM).
You can see from the lower graph, this system did not buy EEM for the whole 2010-2013 period.
Going back to just trading the SP500, what would happen if we added the simple MA rule. Buy as before but only if price is above it's 200-day moving average. Sell as before but also sell if price is less than it's 200 moving average:
Disclaimer: This is a quick and dirty try-out of whether stock/bond correlation can help differentiate bull/bear regimes. It's not meant to be precise but rather to get you started in performing your own tests.
Few thoughts on TAA:
I will caution the reader that when it comes to "TAA" strategies, for the past few years, holding both the S&P500 (SPY) and bonds (IEF) was an exceptional strategy whether you timed it or not. That is mostly due to the fact that IEF, the 10-year treasury proxy had both an exceptional run and a fairly uncorrelated one to the stock index. As others have mentioned, TAA systems may have a hard time delivering if Treasury yields stop dropping (below zero..?). But one way to look at the typical TAA strategy is that it is a diversified "short-the-dollar" strategy. Looking at it that way, there is room to diversify to non -U.S. denominates assets.
The code in Amibroker:
/----Code by Sanz P.-----------------------------------------------------//
MAshort=Optimize("MA short period",220,10,300,10);
Buy=MoreCorrelated AND newmonth;// AND abovema;
Sell=(!MoreCorrelated /*OR !abovema*/) AND newmonth;
Buy=!MoreCorrelated AND newmonth ;
Sell=MoreCorrelated AND newmonth;
PosQty =Param("How many Positions",1,1,20,1);
SetOption("MaxOpenPositions", PosQty );