Mean Reversion system from Financial-hacker.com, SPY

Posted By: GreenBoat

Mean Reversion system from Financial-hacker.com, SPY - 05/28/17 09:44

I am trying to test the Mean Reversion system from http://www.financial-hacker.com/build-better-strategies-part-2-model-based-systems/

I am testing it on index SPY. I use 2005-2010 EOD data for this test.

I am not sure if I am doing something wrong, but the system doesn't produce trades. So it looks that this system is not suitable for EOD trading on index SPY.

Does it mean that SPY index is not mean reverting. It is trending most of the time? Does it mean that all mean reverting systems wouldn't work on this index or does it mean that only the Hurst exponent is not suitable for this market and time series, but some other mean reverting system might work?

If anyone can write an opinion, it would help me to understand, thanks.

My code:
Code:
/*
Mean reversion system by Financial-Hacker.com
http://www.financial-hacker.com/build-better-strategies-part-2-model-based-systems/
*/

#include <profile.c>

function run()
{
	StartDate = 20050101;
	EndDate = 20101231;
	BarPeriod = 1440; // 1 day
	BarZone = ET; // SPY is in New York
	BarOffset = 15*60 + 50; // set the bar end to 15:50, 10 minutes before the market close	
	LookBack = 1000;
	asset("SPY");
	set(PRELOAD|LOGFILE|PLOTNOW);
	PlotHeight1 = 800; // height of the chart with results
	PlotWidth = 2000;

	vars Price = series(price());
	vars Filtered = series(HighPass(Price,30));
	vars Signal = series(FisherN(Filtered,500));
	vars HurstVar = series(Hurst(Price,500));
	var Threshold = 1.0;

	if(Hurst(Price,500) < 0.5) { // do we have mean reversion?
		if(crossUnder(Signal,-Threshold))
			reverseLong(1); 
		else if(crossOver(Signal,Threshold))
			reverseShort(1);
	}
	
	plot("HurstVar",HurstVar,3,DARKGREEN);
	plot("HighPass",Filtered,3,BLUE);
	plot("FisherN",Signal,3,BLUE);
}



The result:

Posted By: flare9x

Re: Mean Reversion system from Financial-hacker.com, SPY - 09/19/17 03:36

From my tests, the SPY on a interday basis is mean reverting. There are many ways to capture this and perhaps the above method is not the best. You can capture the mean reverting theme of the S&P500 using simple linear models.

For example:

1. Test a rolling z-score on daily bars, optimize for various look backs and entry / exit thresholds
2. Simple MACD or RSI overbought indicators.

I think you will find that those simple linear models will out perform the above.
Posted By: Brax

Re: Mean Reversion system from Financial-hacker.com, SPY - 09/19/17 09:49

I agree with flare9x.

SPY is clearly mean reverting, at least for now...

In my experience, trying to determine market regime is quite unlikely, no matter how sofisticated your indicators are.

I´ve done a lot of trial with Hurst, MMI and so on and i can tell you the simplest and efficient way is just mixing mean and trend altogether or trying to adapt the exposure of each algorithm based on its own performance.

That is, if mean algo is performing badly, reduce lots or go phantom and viceversa.

We cannot predict future, just manage risk accordingly.

Just my two cents.
Posted By: GreenBoat

Re: Mean Reversion system from Financial-hacker.com, SPY - 09/24/17 11:11

OK, it looks that I have to use intraday data (minute), not EOD data, for this system. Thanks for help.
© 2024 lite-C Forums