The formula
Lots = Risk amount ÷ (Stop distance in pips × Pip value per lot). Risk amount is your balance times your risk percent. The stop distance comes from the gap between your entry and stop loss prices, measured in the pair's own pip size.
Why the pair matters
A pip is 0.0001 on most pairs but 0.01 on JPY pairs. Pip value also depends on the quote currency: one pip on EUR/USD is $10 per lot, but on GBP/JPY it depends on the USD/JPY rate. For cross pairs the calculator asks for that conversion rate so the dollar figures are correct.
Gold and indices
For XAU/USD a pip is a $0.10 move. With a 100 oz contract, one pip on 1 lot is worth $10 and a $1.00 move is worth $100. Index contract sizes differ between brokers, so check your broker's contract specification and edit the contract size field.
Lots are rounded down to 0.01 so you never risk more than planned.