This PosSizer extends the capabilities of the standard position sizing methods, adding some requested options. As with most other PosSizers, define the basic position size as either fixed dollar, percent of equity, or maximum risk percent, and then see the effect of various applied rules.
Each option has a checkbox on the right that either enables or disables it. Options can be freely combined with each other. You have the following possibilities:
- Control the maximum number of open positions across the portfolio,
- Define how many positions to take in a single instrument are allowed,
- Specify maximum long and/or short positions,
- Be able to take only Long or only Short trades - without touching the Strategy code!
- Cap maximum entries per day. For intraday trades, it sums up positions taken during the day.
- Reject a Position if it's Priority value is less than or greater than some threshold
- Reject a Position when candidate trade count (number of Alerts) is above or below some Alert cutoff threshold
- Reduce a position's size to a percentage of the N-day moving average of Volume
- Turn off reinvesting profits (i.e., always use original starting capital to size positions)
- Simulate T+3 rule to reject new trades if there are insufficient funds in cash account due to settlement
- Ability to limit total invested amount ($ or %)
- Ability to reject a position if its size is smaller than a threshold, force the minimum size or adjust the size to a % of equity
- Pick up the custom, flexible percent equity or max % risk directly from Strategy (see below).
- Finally, exclusively for the Max % Risk it's possible to cap the total equity to a specified percentage to avoid skipped signals and increased risk due to a high resulting sizes. Note: the position size can't exceed 100%.
The
"Skipped trade solution" is somewhat similar to the so called "Position Leeway" option in discontinued Wealth-Lab 4 that allowed to include trades if there is insufficient capital. When using 100% of equity sizing, skipped trades due to insufficient capital can be caused by the gap between the basis price and the actual price. For the whys and wherefores of basis price, see the User Guide
> Strategy Window > Backtesting Strategies > 100% of Equity Sizing.- For historical orders, the PosSizer "peeks" at the opening price of the next bar (bar+1) to determine the new basis price for the order
- For real-time alerts, it peeks at the Open.PartialValue (if available) of the incomplete bar ("Ghost bar") to determine the new basis price
Note: trades may still be skipped at 100%; to avoid this, reduce the desired percent equity according to your estimated commission + slippage as a percentage of size (e.g. 100% sizing - 0.05% slippage - 0.05% commission, so final size = 99.9%).
Related option
For last position, use all what's left which can be engaged after pressing the "Max Open Positions" button, allows to eliminate more skipped trades in cash-limited situations. It does so by investing
all available cash for trade [N+1] when you already have [N] open positions. For example: you are sizing positions at 10% equity, you have 9 open positions, there is not enough equity to take the 10th signal - this option takes the final signal, sizing the Alert using all the cash left.
The
"Use .Tag" button, when enabled, allows to define the Percent-Equity or Max % Risk input programmatically i.e. in your Strategy: for instance, according to some technical or fundamental event. The combo box switches the position sizing from percent equity to max % risk. You have two options for passing the percent as a
double value to the PosSizer:
- Either in the LastPosition.Tag property
- Or, if your Strategy employs .Tag for its own purposes, as the parameter of the SetShareSize method. For this to work, together with Use .Tag you should click on the Use SetShareSize button on the left.
Example
This code snippet demonstrates how to assign a
Position.Tag value to use a different % equity sizing depending on stock symbol:
if( BuyAtStop( bar+1, Highest.Series( High,20 )[bar] ) != null )
{
string symbol = Bars.Symbol;
LastPosition.Tag =
(symbol == "AAPL") ? 20.0 : // 20% equity for Apple
(symbol == "MSFT") ? 10.0 : // 10% equity for Microsoft
5.0; // or 5% for anything else
}
Notes and Limitations
- "Max Positions Per Symbol" works for backtests and is not compatible with Alerts.
- "Use SetShareSize" does not work for Alerts (by design).
- "Use Tag" does not work for Alerts (by design).
- "Limit total invested amount" and "Reject/Adjust if position's size is smaller than a threshold" do not work with Futures symbol
- "Use T+3" only applies to cash accounts, so users should use 1:1 margin for this option.
- Bug in WL6: "Max Open Positions" currently does not consider Alerts and works for backtests only. To be fixed by WLD 6.9.24
- Bug in WL6: "Reject on Alerts < >" currently does not consider Alerts and works for backtests only. To be fixed by WLD 6.9.24