Most forex position size calculators online are one formula:
lots = risk / (stop_pips × pip_value)
Enter fullscreen mode
Exit fullscreen mode
That formula is right. The bugs live in the two inputs nobody explains: the pip value, and what you do with the number that comes out. I hit all of these while building a calculator, so here is the version that survives real pairs, written in plain JavaScript.
1. Pip size is not always 0.0001
A pip is the fourth decimal place on most pairs, but the second decimal place on pairs quoted in Japanese yen:
function pipSize ( pair ) { return pair . endsWith ( 'JPY' ) ? 0.01 : 0.0001 ; }
Enter fullscreen mode
Exit fullscreen mode
Hard-code 0.0001 and every USDJPY or GBPJPY result is off by a factor of 100. That is not a rounding error; that is a blown account.
Gold, silver, indices and crypto CFDs have no universal pip.…