Hi,
is it possible to access the number of symbols in the backtest in a PosSizer?
Size:
Color:
Yes, for example by looping through the ActivePositions/Positions properties and counting.
Size:
Color:
I mean DataSetSymbol.Count? How can I access this with ActivePositions/Positions? I dont understand.
Size:
Color:
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?
Size:
Color:
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.
Size:
Color:
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.
Size:
Color:
I have just entered a support ticket.
Is there any workaround you can think of in the meantime?
Size:
Color:
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?
Size:
Color:
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.
Size:
Color:
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.
Size:
Color:
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).
Size:
Color: