PosSizer: Number of symbols in DataSet
Author: dansmo
Creation Date: 1/10/2011 4:18 AM
profile picture

dansmo

#1
Hi,

is it possible to access the number of symbols in the backtest in a PosSizer?
profile picture

Eugene

#2
Yes, for example by looping through the ActivePositions/Positions properties and counting.
profile picture

dansmo

#3
I mean DataSetSymbol.Count? How can I access this with ActivePositions/Positions? I dont understand.
profile picture

Eugene

#4
The number of symbols in a DataSet is pretty different from what you initially asked, namely "the number of symbols in the backtest". Topic name corrected.

The DataSetSymbols property is not available to PosSizers. Why would you access the DataSetSymbols.Count in a PosSizer?
profile picture

dansmo

#5
The reason is:
I have a possizer that calculates contract size depending on volatility and a maximum of contracts derived from equity, if vola is very low for example.
Now this is easy with just one symbol in the backtest.
When I have three symbol I´d like to set maximum position size to equity/3. So, I need access to DataSetSymbols.Count. to calcualte equity[bar]/DataSetSymbols.Count.
profile picture

Eugene

#6
Call it shortcoming or design limitation, but there's no "GetDataSetName" property in WealthScript and it's unlikely that you get the same (DataSetSymbols) from PosSizers.

Your support ticket with feature request might be pertinent.
profile picture

dansmo

#7
I have just entered a support ticket.
Is there any workaround you can think of in the meantime?
profile picture

dansmo

#8
Is it possible to launch a Textbox when the PosSizer is called by WLD, so that the user can enter numbers and the PosSizer can work with it?
profile picture

Eugene

#9
IMO that would be poor design given that there already is a standard documented GUI for configuring PosSizers. Check out the demo PosSizer's source code in the Wiki.
profile picture

dansmo

#10
OIC. So as a workaround there just need to be a field indicating the number of symbols. Thats okay. But access directly would be much better, of course.
profile picture

Eugene

#11
Yes. Alternately, as a quick & dirty workaround you may assign any value (i.e. DataSetSymbols.Count) to the Bars.Tag property in your Strategy whenever an Alert is generated and read that value back in the PosSizer (don't forget to cast it in PosSizer before using or you'll get a compiler error).
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).