# Index mean reversion system - any tips?



## Gringotts Bank (8 June 2012)

Would be nice to have a system for trading an index long and short, (EOD) say the SPY.  

I'm thinking along the following lines:

SPY downtrending
buy when the gap between the close and the MA of the close is greater than x.
sell when the gap contracts.

SPY uptrending 
short when gap between the close and the MA of the close is greater than x.
cover when the gap contracts.

SO far my tests aren't yielding anything.

Any suggestions please?


----------



## sinner (8 June 2012)

Gringotts Bank said:


> Would be nice to have a system for trading an index long and short, (EOD) say the SPY.
> 
> I'm thinking along the following lines:
> 
> ...




Double 7s http://www.thepatternsite.com/Double7sSetup.html (Bulkowski more like 2/11)
2 days up in chop http://quantifiableedges.blogspot.com.au/2009/10/whats-happened-to-2-days-up-in-chop.html
DV2 http://cssanalytics.wordpress.com/2010/11/22/dv2-performance-in-review/ (DVO is the best oscillator for adaptiveness)
RSI2 (can combine with ADX, or or whatever)
5 sto http://newsletter.neoticker.com/2005/11/13/stock-trading-using-stochastics-end-of-day/
vol pivots http://www.verticalsolutions.com/notes/simple_pivot_system.html
Daily mean reversion (autocorrelation)

There are heaps of such systems. Adaptiveness is key.

http://quantumfinancier.wordpress.com/2010/05/14/using-probability-density-as-an-adaptive-mechanism/


----------



## Trembling Hand (8 June 2012)

sinner said:


> * Adaptiveness is key.*




Made the important bit pretty for emphases.


----------



## Gringotts Bank (8 June 2012)

I had a feeling you might have a few decent links up your sleeve sinner.  Thanks!


----------



## sinner (8 June 2012)

A few others from my own notes

Long RSI2<30 when TVA > 1 and position size = TVA.
S/R pivots - limit long at the avg 2-3day low shifted back 1, limit short at inverse.
Mean reversion based off breadth (similar to 5sto)
Trade ROC1 when Raff channel <> 1stddev


----------



## Trembling Hand (8 June 2012)

Gringotts Bank said:


> SO far my tests aren't yielding anything.




What data are you using? and why use SPY?


----------



## Gringotts Bank (8 June 2012)

Trembling Hand said:


> What data are you using? and why use SPY?




I just downloaded SPY from a free source.  As EOD data it looks quite clean.  What other instrument would you suggest using (other than futs contracts)?


----------



## Gringotts Bank (8 June 2012)

Anyone know where to find the source code for DVB?  [Amibroker]

EDIT:

Just in case anyone else interested: $695

http://dvindicators.cssanalytics.com/product/oscillators-and-mean-reversion-indicators/


----------



## Trembling Hand (8 June 2012)

Gringotts Bank said:


> I just downloaded SPY from a free source.  As EOD data it looks quite clean.  What other instrument would you suggest using (other than futs contracts)?




I don't get why you would EOD?

And why not use something in our time zone. Why would you set yourself up for working night shift.


----------



## Gringotts Bank (8 June 2012)

Trembling Hand said:


> I don't get why you would EOD?
> 
> And why not use something in our time zone. Why would you set yourself up for working night shift.




Our time zone would be better.  EOD = easier if I'm at work I can't always monitor open trades.  My main interest is finding some system that can be traded when the Aus stock market is dead, like at the mo.   What would you suggest?


----------



## Trembling Hand (8 June 2012)

Gringotts Bank said:


> My main interest is finding some system that can be traded when the Aus stock market is dead, like at the mo.   What would you suggest?




Our time zone = K200 is a ripper but not sure if there is a CFd, HSI, HHI, STW (Taiwan) Nikkei, 

Euro Time zones = DAX is an absolute ripper at the mo. Z (ftse).

All these can be traded with CFDs if you don't want to go to the large tick sizes of futs.

Then of course there is FX?


----------



## Joules MM1 (8 June 2012)

Gringotts Bank said:


> Our time zone would be better.  EOD = easier if I'm at work I can't always monitor open trades.  My main interest is finding some system that can be traded when the Aus stock market is dead, like at the mo.   What would you suggest?




consider any instrument that is highly liquid and know when most likely to be at highest liquidity, like gold or silver where you can get inter market ideas too and you can break down size (cfd allows you to get away from 25/tick deal)

not sure any cfd does kospi....


----------



## CanOz (8 June 2012)

Trembling Hand said:


> Our time zone = K200 is a ripper but not sure if there is a CFd, HSI, HHI, STW (Taiwan) Nikkei,
> 
> Euro Time zones = DAX is an absolute ripper at the mo. Z (ftse).
> 
> ...




Agree on the K200 - very mean reverting intra-day, counter trend.

CanOz


----------



## Joules MM1 (8 June 2012)

mean reversion systems.......hmmmmmm


----------



## sinner (8 June 2012)

Gringotts Bank said:


> Anyone know where to find the source code for DVB?  [Amibroker]
> 
> EDIT:
> 
> ...




Yeah the basic code has been public forever, what you buy is his 'model', i.e. what any good trader should be developing themselves.



(from the MRSwing NAAIM paper by Abrams & Walker)

I posted the blog link to 'differential DV2' in the pairs trading thread, which shows how to calculate the DV2 for a single instrument (as a component of the differential).


----------



## sinner (8 June 2012)

Joules MM1 said:


> mean reversion systems.......hmmmmmm




all good so long as there's vol, vol is the highly (relatively anyway) predictable mean reverting component of price. Differentiate between different 'regimes' in the market, as they call it in the MRSwing paper, and *adapt* to them.


----------



## Joules MM1 (8 June 2012)

sinner said:


> all good so long as there's vol, vol is the highly (relatively anyway) predictable mean reverting component of price. Differentiate between different 'regimes' in the market, as they call it in the MRSwing paper, and *adapt* to them.




price can move back through territory regardless of volume because the volume is relative to the time and participants that moved it previously and not necessarily in the present which is where you're transacting.......what the auction at that time is establishing determins pricing.......if volume is always balanced every sell is met by equal buys then volume itself is not determinant of anything whereas the participants are.......that sounds obvious i know, which is why people think that more volume means more people (not true) and more volume means more price discovery (also not necessarily true) but the TRADERS at the TIME determin HOW much price territory is used not how much price discovery is sought.........imho

oh dear.......coffee


----------



## sinner (8 June 2012)

Joules MM1 said:


> price can move back through territory regardless of volume because the volume is relative to the time and participants that moved it previously and not necessarily in the present which is where you're transacting.......what the auction at that time is establishing determins pricing.......if volume is always balanced every sell is met by equal buys then volume itself is not determinant of anything whereas the participants are.......that sounds obvious i know, which is why people think that more volume means more people (not true) and more volume means more price discovery (also not necessarily true) but the TRADERS at the TIME determin HOW much price territory is used not how much price discovery is sought.........imho
> 
> oh dear.......coffee




hehe sorry Joules, I meant vol as in volatility, high vol increases mean reversion and negative autocorrelation tendencies in the time-series because vol itself is 'predictably' mean reverting.


----------



## Gringotts Bank (9 June 2012)

Thanks for everyone's input.

sinner, have you used any of the DV indicator models?  Worth $695?  There's no way I could translate that equation into anything useful - beyond me.


----------



## sinner (9 June 2012)

Gringotts Bank said:


> Thanks for everyone's input.
> 
> sinner, have you used any of the DV indicator models?  Worth $695?  There's no way I could translate that equation into anything useful - beyond me.




GB, it's a very simple calculation. I was hoping you'd make the effort to try at least! I never bought anything off the CSS Analytics website, all coded myself from the algorithms provided by David Varadi on his blog. If you don't understand the underlying what is the point of paying for the model.

Michael from marketsci has done the work for you in excel

http://marketsci.wordpress.com/2009/07/22/roundup-dv2/

The DVO is definitely "worth it", because it has so many options for adaptivity. You don't have to use the DV2 on everything, and I don't. There are 'optimal' settings/weights depending on the security in question and the regime it's in. If you can build some adaptivity into your trading rules you can trade 'around' (not chase) the most optimal settings. Check out the quantumfinancier blog post above for a basic example using RSI2 (although I would caution against trading the 'top' returning score, rather an aggregate score for the top N%). Also check out the very interesting recent post by DV on his blog titled "Derivative Optimization", introduces some interesting ideas about MVP and Risk-Parity on indicators.


----------



## Gringotts Bank (26 June 2012)

sinner, I don't know what the variables represent in that DV equation.  Can you help?  Would like to code it for AB if possible.


----------



## sinner (26 June 2012)

Gringotts Bank said:


> sinner, I don't know what the variables represent in that DV equation.  Can you help?  Would like to code it for AB if possible.




Dude I posted a link with excel spreadsheets on how to calculate it. Surely you can reverse engineer that?

I'll run a simple example for crude DV here, please only use it as an example to understand the equation.

I'm using my own variables here, so please try to stay with me.

Let's say we are interested in 2 day mean reversion, and we want to weight each days values equally amongst the total days. So n=2 and w=0.5 (1/n=1/2=0.5)

UnboundedDV2TodayEOD = (X*w)+(Y*w) where
X=(TodaysClose/((TodaysHigh+TodaysLow)/2)-1)
Y=(YesterdaysClose/((YesterdaysHigh+YesterDaysLow)/2)-1)

BoundedDV2TodayEOD = PercentRank(DV2TodayEOD, 252)
where PercentRank(Z,D) returns the rank of Z across the array of the last D values for Z, as a percentile. (this is an Excel function, so you can hop on MSDN to find good info on it)

That's the basic DV2, which is a 'SPY optimised' version of the general DVOscillator, where n can be any value (e.g. you could have a DV3 or DV72) and w can be independent for each value calculated (e.g. you could have DV3 where todays value weighs 0.5, yesterdays 0.3 and the day before 0.2). So n and w can be adaptive/optimised parameters, or adjusted per security. You can also adapt on entry threshold values such that the indicator switches from 'mean reversion' to 'follow through' based on your adaptation engine. Indicator values for the bounded version are naturally adaptive.

I'll post the marketsci link again
http://marketsci.wordpress.com/2009/07/22/roundup-dv2/


----------



## Gringotts Bank (26 June 2012)

sinner said:


> Dude I posted a link with excel spreadsheets on how to calculate it. Surely you can reverse engineer that?
> 
> I'll run a simple example for crude DV here, please only use it as an example to understand the equation.
> 
> ...




Thanks.

I seem to be getting a syntax error, not sure why.  w and ww were initialized.  Am I close?

unboundeddv2 = (((C/((H+L)/2)-1))*w  +  ((Ref(C,-1)/((Ref(H,-1)+Ref(L,-1))/2)-1))*ww;


----------



## Gringotts Bank (27 June 2012)

Gringotts Bank said:


> Thanks.
> 
> I seem to be getting a syntax error, not sure why.  w and ww were initialized.  Am I close?
> 
> unboundeddv2 = (((C/((H+L)/2)-1))*w  +  ((Ref(C,-1)/((Ref(H,-1)+Ref(L,-1))/2)-1))*ww;




ok one too many brackets.  No syntax now, but the plot seems a bit out.

unboundeddv2 = ((C/((H+L)/2)-1))*w  +  ((Ref(C,-1)/((Ref(H,-1)+Ref(L,-1))/2)-1))*ww;


----------



## Monkeyzu (16 July 2012)

http://quantingdutchman.wordpress.com/2010/08/06/dv2-indicator-for-amibroker/


----------



## Gringotts Bank (17 July 2012)

Monkeyzu said:


> http://quantingdutchman.wordpress.com/2010/08/06/dv2-indicator-for-amibroker/




Thanks


----------

