Lot sizing function gotchas across JPY pairs and gold, the bug that over-risked me
Posted: Wed Oct 07, 2026 11:22 pm
Lot sizing function gotchas across JPY pairs and gold, the bug that over-risked me
wrote an equity based position sizing function for my EA, risk a fixed percent per trade based on the stop distance. Worked on EURUSD in testing. Then I put it on USDJPY and gold and the risk per trade was completely wrong, either far too big or tiny.
The problem was tick value and tick size. Different symbols have different contract sizes, and the value of one pip or point isn't the same. On JPY pairs a pip is 0.01 instead of 0.0001, and on gold the point size depends on how the broker quotes it. My function assumed a pip meant the same thing everywhere.
The fix was to read the symbol's tick value and tick size from the platform each time, and calculate risk from those instead of hardcoding anything. I also round the lot to the broker's volume step and clamp it between the minimum and maximum allowed. Then I print the calculated money at risk to the log for every order so I can see if it matches what I intended.
Test it on a demo with each symbol you plan to use and check one trade manually before trusting it.
wrote an equity based position sizing function for my EA, risk a fixed percent per trade based on the stop distance. Worked on EURUSD in testing. Then I put it on USDJPY and gold and the risk per trade was completely wrong, either far too big or tiny.
The problem was tick value and tick size. Different symbols have different contract sizes, and the value of one pip or point isn't the same. On JPY pairs a pip is 0.01 instead of 0.0001, and on gold the point size depends on how the broker quotes it. My function assumed a pip meant the same thing everywhere.
The fix was to read the symbol's tick value and tick size from the platform each time, and calculate risk from those instead of hardcoding anything. I also round the lot to the broker's volume step and clamp it between the minimum and maximum allowed. Then I print the calculated money at risk to the log for every order so I can see if it matches what I intended.
Test it on a demo with each symbol you plan to use and check one trade manually before trusting it.