Modern backtest software includes built-in primitives that try to address this. They might or might not be the best possible ideas the mind of man could ever conceive, that's a matter of opinion, but I don't think it's very controversial to say that these built-in primitives are certainly steps in the right direction.
One commonly available set of functions can be incorporated into your trading system's position sizing calculations. For example "TOTALHEAT()" returns the sum of the heat of each position currently in place. Applying it in pseudocode, you might choose to say
- If TOTALHEAT() > (0.25 * TOTALEQUITY()) then skip new trades; set positionsize = 0; don't take more entry signals
- If TOTALHEAT() > (0.25 * TOTALEQUITY()) then take new entry signals at half size
- If TOTALHEAT() > (0.25 * TOTALEQUITY()) then exit the worst performing current trade before entering a new trade at full size
Other functions with similar uses are SECTORHEAT(), TOTALHEATLONG(), TOTALHEATSHORT(), SECTORHEATLONG(), SECTORHEATSHORT(), COUNTTOTALPOSITIONS(), COUNTSECTORPOSITIONS(), and so forth.
The preceding ideas only modify new entry signals and new trades. Another set of functions allows another set of ideas, which modify both new trades
and existing trades. They go by the name "resizing". For example,
- If TOTALHEAT() > (0.25 * TOTALEQUITY()) then exit 25% of the size of each current position; scale down; reduce heat by 25%
- If SECTORHEAT() > (0.5 * TOTALHEAT()) then exit 25% of the size of each position in this sector; this sector is overweighted so reduce it
Grab a user's manual for one of the programs that implement these kinds of functions. It may give you some ideas. Mechanica, Trading Recipes, and Power ST's manuals contain lots of such things. Maybe other programs do too, you could take a look.