I've written some simple code to always set my risk at 1% no matter where my stop loss is set. Here's what it looks like when I open a short position.
SL = 0.002
strategy.entry("open short", false, (strategy.equity*.01)/((high+SL)-close))
strategy.exit("exit short", "open short", stop = high + SL)
This seems to work when I apply it to the chart, as all of the position sizes line up with my math. However, the profit number is wrong. For instance, I have my starting equity set to $1000 and here is the first trade on the chart.
You can see, entry price is 0.63835 and exit is 0.6412, with a difference of 0.00285. That difference multiplied by the amount of contracts (3508) gives me 9.9978, which is the max amount that should have been lost on the trade. This lines up with my 1% stop loss, which should be $10. However, you can see that the strategy tester shows I lost $14.91.
Am I misunderstanding how profit is calculated? Or is this a problem with the strategy tester?