To Infinity and... Beware Infinite Values
By Dave Mabe
One phase traders go through is learning just how important position sizing is.
The same strategy can be dramatically different depending on the sizing approach used. (Good example here).
When you size positions based on your risk (distance to the stop) and then measure performance by risk, it can unlock an entirely new dimension of strategies and ideas.
But be very careful - it's easy to let outliers sneak in a backtest that have inordinately large sizes.
If you're sizing based on distance to your stop, but your stop is really close to your entry, then it's easy to get infinite sizing.
Here's an example.
Let's say you want to risk a certain amount with each trade, say, $100.
In your code, you could size positions like this:
RISK = 100;
entry_price = 50.10;
stop_price = 50.00;
distance_to_stop = entry_price - stop_price;
shares = RISK / distance_to_stop;
In this example, shares is 100 / 0.10 = 1000.
But let's say your stop is closer. Say it's 50.09.
Now your share size is 100 / 0.01 = 10,000.
If you're not careful, this number can get way larger very quickly.
When you go to optimize in the Cruncher, the larger share sizes will naturally weigh more heavily on your analysis.
If you have large outliers, they can make a dramatic difference - even just a trade or two can skew things a lot.
It's helpful to really understand what's going on in your code and put safeguards in place to avoid this, not only when you make trades, but much earlier when you are optimizing.
In the example above, the best approach is to use a floor for the stop_distance so you can control how small that can get.
You should also place a ceiling for your share size in case your code does something you didn't imagine it could do.
-Dave
P.S. Are you sick of second-guessing yourself every time you click buy or sell? Trade with conviction using MabeKit.