Average Volume Limitation PosSizer
Author: Panache
Creation Date: 2/24/2011 8:08 AM
profile picture

Panache

#1
I'm trying to create a PosSizer to limit trades to x% of the average volume calculated over y days. I started by modifying the source code for the Random PosSizer. Here's where I am at this point. I'm sure it's not artful, and any help would be appreciated, especially in regard to how to access the Bars.Volume information and store the variables Percent and Days.

CODE:
Please log in to see this code.
profile picture

Eugene

#2
Add a reference to WealthLab.Indicators.dll before compiling this.
CODE:
Please log in to see this code.


Edit

To avoid some prying eyes, all code was moved to MS123 PosSizers (demo) solution
http://www2.wealth-lab.com/WL5WIKI/MS123PosSizersMain.ashx
profile picture

Eugene

#3
I think that a new filter based on average volume limitation will become a good addition to the Position Options PosSizer.
profile picture

Panache

#4
Awesome Eugene! Thank you.

There was one flaw in my original code. Since the variable Percent is being stored as an integer, it needs to be divided by 100 when calculating the average volume limit.

I also added a line to round the position down to the nearest 100 shares and cleaned up the formatting of the dialog box a little.

Here is my "final" code in case anyone else is interested. Please note, that I do NOT recommend trying to place orders as large as 1% of the average volume. I just used that number as an easy way to test the code.

CODE:
Please log in to see this code.


In order to compile this, Add References to:

C:\Program Files\Fidelity Investments\Wealth-Lab Pro 6\ControlLibrary.dll
C:\Program Files\Fidelity Investments\Wealth-Lab Pro 6\Fidelity.Components.dll
c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\mscorlib.dll
c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\System.dll
c:\Program Files\Reference Assemblies\Microsoft\Framework\v3.5\System.Core.dll
c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\System.Data.dll
c:\Program Files\Reference Assemblies\Microsoft\Framework\v3.5\System.Data.DataSetExtensions.dll
c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\System.Drawing.dll
c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\System.Windows.Forms.dll
c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\System.Xml.dll
c:\Program Files\Reference Assemblies\Microsoft\Framework\v3.5\System.Xml.Linq.dll
C:\Program Files\Fidelity Investments\Wealth-Lab Pro 6\WealthLab.dll
C:\Program Files\Fidelity Investments\Wealth-Lab Pro 6\WealthLab.Indicators.dll
C:\Program Files\Fidelity Investments\Wealth-Lab Pro 6\WealthLab.PosSizers.dll

profile picture

Eugene

#5
You're welcome.
QUOTE:
Since the variable Percent is being stored as an integer, it needs to be divided by 100 when calculating the average volume limit.

I know, in Position Options it will be just like that.
QUOTE:
to round the position down to the nearest 100 shares

Not sure why'd you do that? Already possible in Wealth-Lab's Preferences > Slippage & Round Lots.
(Position Options has a feature to round to next highest N though.)
QUOTE:
In order to compile this, Add References to:

These can be safely dropped from the list, not required:

c:\Program Files\Reference Assemblies\Microsoft\Framework\v3.5\System.Data.DataSetExtensions.dll
c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\System.Xml.dll
c:\Program Files\Reference Assemblies\Microsoft\Framework\v3.5\System.Xml.Linq.dll
profile picture

Panache

#6
QUOTE:
Not sure why'd you do that? You can do it in Preferences > Slippage & Round Lots already.


I thought this rounded to the nearest 100. Because I wanted to limit the trade to a % of the average volume, I wanted to make sure it rounded down and not up, so it didn't exceed my % of average volume.

This is especially important with thinly traded stocks, which is why I wanted to have this PosSizer. A great way to lose money is to put in a market order to buy 1000 shares of a stock that only trades 10,000 shares a day. Not only do you get killed on the purchase, but it isn't easy to get out of the position either!
profile picture

Eugene

#7
Got it.

This option has just been added to the Position Options PosSizer of our PosSizer library.
profile picture

Eugene

#8
This PosSizer's code will be added to our PosSizer pack demo version v2011.11.
This website uses cookies to improve your experience. We'll assume you're ok with that, but you can opt-out if you wish (Read more).