Gamestudio Links
Zorro Links
Newest Posts
Data from CSV not parsed correctly
by EternallyCurious. 04/25/24 10:20
Trading Journey
by howardR. 04/24/24 20:04
M1 Oversampling
by Petra. 04/24/24 10:34
Zorro FIX plugin - Experimental
by flink. 04/21/24 07:12
Scripts not found
by juergen_wue. 04/20/24 18:51
zorro 64bit command line support
by 7th_zorro. 04/20/24 10:06
StartWeek not working as it should
by jcl. 04/20/24 08:38
folder management functions
by VoroneTZ. 04/17/24 06:52
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
5 registered members (AndrewAMD, TipmyPip, VoroneTZ, Quad, 1 invisible), 688 guests, and 11 spiders.
Key: Admin, Global Mod, Mod
Newest Members
Mega_Rod, EternallyCurious, howardR, 11honza11, ccorrea
19048 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Mean Reversion system from Financial-hacker.com, SPY #466163
05/28/17 09:44
05/28/17 09:44
Joined: Nov 2016
Posts: 66
GreenBoat Offline OP
Junior Member
GreenBoat  Offline OP
Junior Member

Joined: Nov 2016
Posts: 66
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:


Re: Mean Reversion system from Financial-hacker.com, SPY [Re: GreenBoat] #468116
09/19/17 03:36
09/19/17 03:36
Joined: Sep 2017
Posts: 7
TX
F
flare9x Offline
Newbie
flare9x  Offline
Newbie
F

Joined: Sep 2017
Posts: 7
TX
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.

Re: Mean Reversion system from Financial-hacker.com, SPY [Re: flare9x] #468124
09/19/17 09:49
09/19/17 09:49
Joined: Aug 2017
Posts: 102
Spain
B
Brax Offline
Member
Brax  Offline
Member
B

Joined: Aug 2017
Posts: 102
Spain
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.

Re: Mean Reversion system from Financial-hacker.com, SPY [Re: Brax] #468200
09/24/17 11:11
09/24/17 11:11
Joined: Nov 2016
Posts: 66
GreenBoat Offline OP
Junior Member
GreenBoat  Offline OP
Junior Member

Joined: Nov 2016
Posts: 66
OK, it looks that I have to use intraday data (minute), not EOD data, for this system. Thanks for help.


Moderated by  Petra 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1