1 - There was a logic error: despite the creation of multiple positions, the code was using single-position patterns like IsLastPositionActive or LastPosition.
2 - Wealth-Lab's architecture does not support accessing portfolio equity in strategies. To overcome this limitation, you can:
a) Rewrite your script to process DataSetSymbols and keep track of Portfolio Equity manually:
Limit Monthly Drawdown / Portfolio Equity Trackerb) Or leave it as is and use this technique:
Interacting Dynamically with Portfolio Level EquityTo set the size as a function of equity, you may:
1) use
SetShareSize() in conjunction with the "WealthScript Override (SetShareSize)" option in the Position Sizing control
2) or if you prefer that the position size adjusts to the changing equity, here are 3 PosSizers from the
MS123 PosSizer library that can be used to specify a percentage of equity directly (more or less). Pick an approach that suits you:
2.1)
Position Sizing with the Trend - through "Signal name options". In your Strategy code, assign an entry signal to your positions (i.e. instead of "Group1"/"Group2" choose something like "bullish"/"bearish" or "stock1"/"stock2") and then make necessary adjustments to the PosSizer dialog.
2.2)
Priority Adjustment PosSizer is similar to a) but here you directly assign a position size as % of equity. Instead of entry signal name, here you assign a Position.Priority value exactly as illustrated in the QuickRef and configure the PosSizer accordingly.
2.3)
Position Options > "Use .Tag". Yet another approach to the same problem. Usage is described in the Wiki manual.