Position Sizing in Backtests
How the way you size trades decides which trades your backtest rewards
How you size positions in a backtest decides how much each trade counts. Total profit, profit factor and drawdown are all in dollars, so the trades with the most dollars at risk drive the results, and the Strategy Cruncher finds filters that keep them.
An Example: Opening Range Breakout
A long opening range breakout: buy when the price breaks above the high of the first five minutes, put the stop at the low of that range, and exit at the close.
Here are four made-up trades:
| Stock | Entry | Stop | Stop distance | Exit | Result |
|---|---|---|---|---|---|
| AAA | $202.00 | $200.00 | $2.00 (1.0%) | $205.00 | +1.5R |
| BBB | $20.50 | $20.00 | $0.50 (2.4%) | $20.00 | −1R |
| CCC | $4.20 | $3.80 | $0.40 (9.5%) | $5.00 | +2R |
| DDD | $150.00 | $148.75 | $1.25 (0.8%) | $148.75 | −1R |
R is the distance from entry to stop. The strategy made +1.5R over the four trades and won half of them. Now size them three ways.
| Stock | 100 shares | $10,000 a trade | $100 risk a trade |
|---|---|---|---|
| AAA | +$300 (risked $200) | +$147 (risked $98) | +$150 |
| BBB | −$50 (risked $50) | −$243.50 (risked $243.50) | −$100 |
| CCC | +$80 (risked $40) | +$1,904 (risked $952) | +$200 |
| DDD | −$125 (risked $125) | −$82.50 (risked $82.50) | −$100 |
| Total | +$205 | +$1,725 | +$150 |
Same entries, same exits, same win rate. Three very different backtests.
Constant Shares
Every trade is the same number of shares. The risk on a trade is the shares times the stop distance in dollars, so risk grows with the stock's price.
In the example, the risk ranges from $40 to $200. AAA made 146% of the total profit; CCC's 2R winner barely shows up.
The bias: expensive stocks dominate. Filters favor whatever the expensive stocks have in common, and a minimum price filter looks great. Cheap stocks look like they don't matter, whether they work or not.
Constant Dollars
Every trade is the same position value. The risk is the position value times the stop distance in percent, so risk grows with the stock's volatility.
In the example, the risk ranges from $82.50 to $952. CCC, the cheapest and most volatile stock, made 110% of the total profit by itself.
The bias: volatile, low-priced stocks dominate. In the example, CCC risked more than ten times what DDD did. Filters favor wide ranges, high volatility and low prices. Cheap stocks also buy the most shares, so they pay the most commission. See Commissions in Backtests.
Risk-Based
Every trade risks the same amount: shares = risk ÷ stop distance. In the example, each trade risks $100.
Each position is sized to what the stock is doing right now. A stop at the low of a wide opening range means fewer shares; a tight range means more. A stopped-out trade loses the same on a $200 stock as on a $4 one.
The results are just R times $100: +$150 is +1.5R. No trade carries the backtest because of its price or its volatility. The only thing that makes a trade count more is that it went further in R.
That makes risk-based sizing the most normalized of the three. More of your trades count equally, so the equity curve is usually smoother and the returns more consistent, and the filters the Strategy Cruncher finds reflect the setup, not the sizing.
The bias: tight stops mean big share counts.
- Commissions. At $0.005 a share each side, the commission in R is $0.01 ÷ the stop distance. A 5-cent stop costs 0.2R a trade. See position sizing in Commissions in Backtests.
- Outliers. A stop a few cents from the entry can produce a huge position. Cap the shares or the position value. See Watch Out for Outliers.
- Liquidity. A large share count in a thin stock may not be tradable. See Liquidity Filters.
Sizing Doesn't Change Win Rate
Win rate counts trades, not dollars, so it's the same under every sizing. Profit factor, average trade, total profit and drawdown all change. If a filter looks good on profit factor but not on win rate, check whether a handful of large positions is behind it.
Setting It Up in AmiBroker
// Constant shares
SetPositionSize(100, spsShares);
// Constant dollars
SetPositionSize(10000, spsValue);
// Risk-based: $100 a trade, capped at 50,000 shares
Risk = 100;
StopPrice = ORLow; // the low of the opening range
SetPositionSize(Min(Risk / (BuyPrice - StopPrice), 50000), spsShares);
If you backtest without a stop, still size from where the stop would be.
Trade Ideas OddsMaker exports only each trade's move, so the Strategy Cruncher uses constant-dollar sizing of about $1,000 a trade. Keep the constant-dollar bias in mind when you read an OddsMaker report.