From Regime Switching to Fuzzy Logic -SP500


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);

This article was updated on

Related post

QUANTtrader -The Logical-Invest investment software for building and backtesting rules-based strategies

Quanttrader Logical Invest's swiss army knife

Investment software to easily create and backtest a rules-based investment strategy

QUANTtrader is a swiss-made software tool used to develop, backtest and implement rules-based strategies. It was initially developed by Frank Grossmann as his personal investment software. After having sold two companies, Frank trades for a living and his software reflects this. QuantTrader is available from Logical-Invest.com for a monthly license.

Quanttrader Logical Invest investment Software demo

Since it is built by a trader and long-time  investor rather than by a  developer. QuantTrader's main strength is in building medium to long term investment portfolios that are diverse, adaptive and can control risk. All this without writing a single line of code.

Simple Regime Switching for SP500

black-in-white-big-300x225
image from  http://brucekrasting.com/

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.

2013-08-21_0314-300x219
Mean Reversion Trading On SP500
2013-08-21_0315-300x220
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.

2013-08-21_0313-300x215
Here's the Amibroker Code:
 

SanzP joins Logical-Invest

I joined the team at Logical-Invest.

Together with Frank, Alex and Scott (our info) we hope to create a place where we can develop strategies and actually offer them to the public for a low subscription.

This is something new. At least I think so.

If you have followed my blog you may have guessed that I support empowering the private investor to take investing into their own hands and use tools as good or better than the 'big guys' use. But I also understand that not everyone can become a full-time trader, learn programming or research the market for hours on end. Luckily there are quite a few management firms that are intelligent, publish their research, have good track records and are fairly priced.

We are taking a different route.