Programmatically Control Alert Shares
Author: innertrader
Creation Date: 6/13/2018 7:58 PM
profile picture

innertrader

#1
The PosSizer LastPosition.Tag option for sizing positions based on %Equity is terrific and very useful for backtesting. As you note, it cannot be used to control alert share values for trading.

Is there any way to programmatically pass the number of shares to an alert? If so, can you point me to code samples? Are there hooks to create a custom alert?
profile picture

Eugene

#2
Nothing new under the sun:

FAQ | Position Sizing, Extensions, Miscellaneous > How to pass a value from Strategy to PosSizer for Alert sizing?
profile picture

innertrader

#3
Do I have to custom code a new PosSizer class per the documentation "Creating a PosSizer in Wealth-Lab Pro" or is there something existing I can build on? Any code examples of either?


I found my way to http://www2.wealth-lab.com/WL5WIKI/MS123PosSizersMain.ashx but can't figure out how to download the project code.


To be clear about my objective, I don't need anything custom to size the position, only to get the share result into alert messages when I am using PosSIzers > Position Options > .Use .Tag > % Equity
profile picture

Eugene

#4
QUOTE:
Do I have to custom code a new PosSizer class

Yes but the open source code in the Wiki that you referred to already contains an example of what you're looking for:

Script-based Percent Equity: sizes position according to a % of equity passed as a Position.Tag value (double) or via SetShareSize (option exists in Position Options)

Once you sign up for Wiki account and it gets greenlisted you could simply reuse the project with minimal tweaks. Be sure to:

1. change output path if debugging (currently set to Program FilesMS123/Wealth-Lab Developer 6 which doesn't exist on your machine) to your Wealth-Lab Pro 6 installation folder
2. point the broken references to WealthLab.dll et al. to your WLP6 folder again (they're also preset for the WLD path)
3. (optional) delete all the classes but ScriptBasedPctEq.cs if you don't need them
4. (optional) rename the output assembly MS123.PosSizers.demo.dll to something of your taste
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).