Australian (ASX) Stock Market Forum

CPI - adjusted liquidity filter

Joined
5 January 2006
Posts
4,461
Reactions
1
Hi,

Does anybody know how to code for a CPI-adjusted liquidity filter when backtesting using metastock/tradesim?

There was some discussion the other day, i brought up the point that a $10 price filter would not be as restrictive as it was during backtesting when you think about the future going forward, and equities as growing businesses/companies where the ones that survive are usually the ones that prosper.

A logical extension of this as another member highlighted would be the same problem with liquidity. Since liquidity or money flow is a function of the stock price a liquidity filter wouldnt be as restrictive now as it was, say 10years ago.

So a CPI-adjusted liquidity filter would be an interesting idea, since i can recall, somebody mentioned that there were 42-odd companies in 1997 with liquidity>$500,000 and about 200 companies today.

Any thoughts, ideas, discussion, would be much appreciated.
 
Nizar,

Here's my attempt at solving the problem!

{Start}
{Metastock CPI (Australia) Turover Filter - written in Metastock v9 and will need to be modified for use after 2007}
Base:=500000;{Enter minimum system turnover for 2007 eg 500000}
YEARVAL:=If(Year()=2007,Base,If(Year()=2006,Base/1.033,
If(Year()=2005,Base/1.061,If(Year()=2004,Base/1.089,
If(Year()=2003,Base/1.115,If(Year()=2002,Base/1.148,
If(Year()=2001,Base/1.184,If(Year()=2000,Base/1.253,
If(Year()=1999,Base/1.276,If(Year()<=1998,Base/1.296,Base*20))))))))));{End}

{If you wish to use this filter when back-testing copy from "{Start} to {End}" inclusive and paste it at the beginning of MetaStock exploration code.
You will also need to amend the Turnover Filter in the EntryTrigger to show "YEARVAL" instead of an amount, for example,
Mov(V*C,21,S)>=YEARVAL;}

The above code can undoubtedly be simplified and the resultant simplification may allow a longer lookback period.
If we could just attract the attention of a learned MetaStock carrot-munching mammal from the hare family we will have our answer.

Whilst every endeavor has been made to ensure this code offers a basic CPI related turnover filter I would recommend that you validate the results of including this code in your back-testing before relying on any outcomes.

Basis of Calculation

Qtr Ending Au/CPI Year CPI Factor (Rounded to 3 Decimal Places)

31/12/2006 155.5 2007 155.5/155.5
31/12/2005 150.6 2006 155.5/150.6
31/12/2004 146.5 2005 155.5/146.5
31/12/2003 142.8 2004 155.5/142.8
31/12/2002 139.5 2003 155.5/139.5
31/12/2001 135.4 2002 155.5/135.4
31/12/2000 131.3 2001 155.5/131.3
31/12/1999 124.1 2000 155.5/124.1
31/12/1998 121.9 1999 155.5/121.9
31/12/1997 120.0 1998 & earlier 155.5/120.0

Unfortunately I can't get this table to post as I would prefer which obviously highlights my total lack of knowledge in making posts.
 
If we could just attract the attention of a learned MetaStock carrot-munching mammal from the hare family we will have our answer.

Rob I think your from the same Burrough!
 
Nizar,

Here's my attempt at solving the problem!

{Start}
{Metastock CPI (Australia) Turover Filter - written in Metastock v9 and will need to be modified for use after 2007}
Base:=500000;{Enter minimum system turnover for 2007 eg 500000}
YEARVAL:=If(Year()=2007,Base,If(Year()=2006,Base/1.033,
If(Year()=2005,Base/1.061,If(Year()=2004,Base/1.089,
If(Year()=2003,Base/1.115,If(Year()=2002,Base/1.148,
If(Year()=2001,Base/1.184,If(Year()=2000,Base/1.253,
If(Year()=1999,Base/1.276,If(Year()<=1998,Base/1.296,Base*20))))))))));{End}

{If you wish to use this filter when back-testing copy from "{Start} to {End}" inclusive and paste it at the beginning of MetaStock exploration code.
You will also need to amend the Turnover Filter in the EntryTrigger to show "YEARVAL" instead of an amount, for example,
Mov(V*C,21,S)>=YEARVAL;}

The above code can undoubtedly be simplified and the resultant simplification may allow a longer lookback period.
If we could just attract the attention of a learned MetaStock carrot-munching mammal from the hare family we will have our answer.

Whilst every endeavor has been made to ensure this code offers a basic CPI related turnover filter I would recommend that you validate the results of including this code in your back-testing before relying on any outcomes.

Basis of Calculation

Qtr Ending Au/CPI Year CPI Factor (Rounded to 3 Decimal Places)

31/12/2006 155.5 2007 155.5/155.5
31/12/2005 150.6 2006 155.5/150.6
31/12/2004 146.5 2005 155.5/146.5
31/12/2003 142.8 2004 155.5/142.8
31/12/2002 139.5 2003 155.5/139.5
31/12/2001 135.4 2002 155.5/135.4
31/12/2000 131.3 2001 155.5/131.3
31/12/1999 124.1 2000 155.5/124.1
31/12/1998 121.9 1999 155.5/121.9
31/12/1997 120.0 1998 & earlier 155.5/120.0

Unfortunately I can't get this table to post as I would prefer which obviously highlights my total lack of knowledge in making posts.

rnr.
Good work brother, very much appreciated.

Yes that Wabbit is a gun, lets hope he sees this.
 
Hmmmm had a bit of a think about this just this morning, and CPI doesnt really have much to do with the stockmarket does it?

Maybe the filter needs to be, not CPI-adjusted, but rather, adjusted by the average annual % increase in the market, which is about 8%p.a (XAO during the last 19 years).

I'll try to give this a go based on the work done by rnr.
 
If you want to accomodate for changes in liquidity/turnover, couldn't you just calculate how that changes year on year (by doing a ratio of moving averages) and then adjust accordingly?
 
If you want to accomodate for changes in liquidity/turnover, couldn't you just calculate how that changes year on year (by doing a ratio of moving averages) and then adjust accordingly?

Any ideas how to express this is metastock code?
 
Being the devil's advocate what is the function of a liquidity filter?

Is the liquidity I need for a $30,000 account the same as for a $1,000.000 account?

In TradeSim there is a built in liquidity filter under the preferences tab (limit position size to a maximum of X% of traded volume). Surely this controls the liquidity risk to a large degree. You could also add a liquidity filter as well to only detect shares with a minimum threshold as well.

Cheers

Shane
 
Being the devil's advocate what is the function of a liquidity filter?

Is the liquidity I need for a $30,000 account the same as for a $1,000.000 account?

In TradeSim there is a built in liquidity filter under the preferences tab (limit position size to a maximum of X% of traded volume). Surely this controls the liquidity risk to a large degree. You could also add a liquidity filter as well to only detect shares with a minimum threshold as well.

Cheers

Shane

Agree, TradeSim is great.
I use both that filter and one coded into my entry.

Shane, have you read BlackStar's study on trend following?
They used a dynamic CPI-adjusted liquidity filter.

I thought it was an interesting idea because when backtesting, say to 1992, a $500k per day liquidity filter, or even a $1m a week liquidity filter, will be much more restrictive than it is today.
 
Also when thinking of liquidity you have to also take into account that some securities may have missing days due to trading halts etc.

In Jose's URSC kit he has a very good Liquidity filter which takes that into account as well as no range bars. He also allows % tolerance for no range bars and no trade bars.
 
Also when thinking of liquidity you have to also take into account that some securities may have missing days due to trading halts etc.

In Jose's URSC kit he has a very good Liquidity filter which takes that into account as well as no range bars. He also allows % tolerance for no range bars and no trade bars.

The price is also very good at 395 Euro!!
 
Hi Nizar

I use the TradeSim filter and my selection of shares for my liquidity filter (asx 200/300). The reason I posed the question is that the liquidity filter has real issues based on database periods eg 1999-2003 would be different to 2003-2007 as you have discovered.

I feel it would be more important to understand the function of a liquidity filter. In my view the function of a liquidity filter is to select shares that are easier to exit than less liquid shares. In my trading experience it is a lot easier to get into a share than get out of it at the price I'd like. So I tend to trade more liquid universes of shares such as the asx 200 and asx 300. I also prefer low drawdown systems that I can use with leverage to boost returns at appropriate time.

I prefer weekly long side equities systems and as such choose to test using robust methods such as average price for the week and entering on the high and exiting on the low. This is quite robust form of in sample stress testing and is very useful, I find.

Unfortunately Metastock has limited functions for checking whether a share was in an index at the time of testing. This can be done with other software such as WealthLab and probably (although I haven't tried it yet)..Amibroker. This method helps eliminate survivorship bias.

I admire you for continuing this journey publicly on the forum. The great thing is that you are being guided toward a hopefully profitable and robust system that you can have confidence in.

Cheer and good luck

Shane
 
Top