In rules-based-investing we define a clear set of rules. These rules comprise an investment strategy. Here is an example strategy: “At the first day of the month, look at the performance of bonds versus stocks by calulating the 3-month performances of two exchange traded funds, SPY (the SPDR S&P 500 ETF) and TLT (the iShares 20+ Year Treasury Bond ETF). If SPY outperforms, then re-balance the portfolio to 60% SPY, 40% TLT. If not, rebalance to 40% SPY, 60% TLT.”

Why follow an Investment Strategy?

It eliminates our main weakness, emotion.

Developed through years of evolution, our basic human instincts are necessary for our survival. Keeping with the laws of the jungle, these instincts push us to run when in danger and charge when we see opportunity. The stock market, much like a casino, is built to take advantage of these instincts. Investors, if left to their primitive fear/greed instincts, tend to buy high and sell low.

Historically and up to 2013, equities have exhibited a positive bias during the end of the month.
Here is an example of buying the SPY etf on the first down-day after the 23rd and selling on the first up-day of the next month. Trading is at the same day close.

This has been well documented in academic papers as well as blogs. The main reason quoted for this persistent bias has been end-of-month window dressing.

As one of my favorite author/blogger/trader, Mr. Grøtte, has also recently blogged the EOM bias is no more.

Why is this important to know?

A lot of investors re-balance monthly. The day of the re-balance used to be somewhat important as there was an EOM bias. So it was better to ‘buy’ at the end of the month rather than at the beginning of the month. As of late (2013) this is less true.

What this means in practice is that the specific timing for re-balancing monthly strategies may be less important than it used to be.

//Amibroker code:
Buy=Day()>=23 AND C<Ref(C,-1) ;//AND C>MA(C,100);
Sell= (Day()<11 AND C>Ref(C,-1));
SetTradeDelays(0,0,0,0);
slip=0.00;
BuyPrice=c+slip;
SellPrice=c-slip;
posqty=Param("nUMBER OF pOSITIONS",1,1,30,1);
SetOption("MaxOpenPositions",posqty);
PositionSize=- 98/posqty;
bars = 10; // exit after 10 bars
ApplyStop( stopTypeNBar, stopModeBars, bars, True );

In the previous post I showed how one can implement “regime” switching to create a strategy that switches between a mean-reverting and a momentum sub-strategy.

Can we do something similar (or better) using Fuzzy Logic?

Here’s the setup: (here for some Fuzzy Logic backround)

We create a basic membership function for the RSI(2) indicator: “Low”, Medium” and “High” We create a basic membership functions for the Correlation* indicator: “Low”,”High”.

We implement these rules: 1.//mean revert – LOW Autoccorelation IF “rsi” is “Low” AND “autocorrel” is “Low”, “Action”, 1 ; //Buy IF “rsi” is “High” AND “autocorrel” is “Low”, “Action”, -1 ; //Sell

//MOM – HIGH Autocorrelation IF “rsi” is “Low” AND “autocorrel” is “High”, “Action”, -1 ; //Sell IF “rsi” is “High” AND “autocorrel” is “High”, “Action”, 1 ; //Buy

Here’s the Equity:

Conclusion: As with Regime switching we can use Fuzzy Logic to solve the problem of using one strategy for trading pre- and post-2000 SP500. Furthermore, we have more robust and less specific rules to deal with (buy on “Low” RSI rather than Buy=RSI2<30).

————— *By “Correlation Indicator” I am referring to the 22-day Correlation (see previous post) between the current return and the previous day’s return. In Amibroker Code: Dayreturn=ROC(C,1); AutoCor=Correlation(Dayreturn,Ref(Dayreturn,-1),22);

Let us consider two possible ways to trade the SP500.

1. If the index falls today, we buy tomorrow at the open. This is a “mean-reversion” strategy.
2. If the index rises today, we buy tomorrow at the open. A “follow-through” strategy.

From the graphs below, we can see that neither of these strategies worked well from 1960 to today.

Mean Reversion Trading On SP500

Follow-Thru (momentum) trading on SP500

Let’s introduce a qualifier that will tell us which strategy to trade at what time.

We will try the most basic one: The correlation between today’s return (close to yesterday’s close) to the previous day’s return. If it is negative we ‘ll use a contrarian logic. If the correlation is positive we ‘ll use a momentum logic.

The indicator of choice is the 2-period Relative Strength Index (RSI).

So if correlation between yesterday’s and today’s return is less than zero we buy on a correction. Otherwise we buy on strength. We trade at the next Open.