This page documents the exact formula behind every ForexFin calculator. Each tool runs deterministically in your browser — given the same inputs and the same reference rate, it returns the same number, every time. We publish the math so you can audit it, reproduce it, and cite it. Nothing here is investment advice; it is arithmetic.
Where a calculation needs a live exchange rate (for cross-currency conversion), we use European Central Bank
reference rates via frankfurter.dev, with Financial Modeling Prep daily closes for the market-data pages.
Conventions used throughout: a standard lot is 100,000 units of the base currency; a pip is
0.0001 for most pairs and 0.01 for JPY-quoted pairs; rates are expressed as
units of the quote currency per one unit of the base currency.
Position sizing answers one question: how many lots can I trade so that hitting my stop costs exactly my planned risk? You first fix the risk budget as a fraction of account equity, then divide it by the cost of the stop.
risk_amount = equity × risk_fraction
risk_per_lot = stop_distance_pips × pip_value_per_lot
lots = risk_amount ÷ risk_per_lot
The pip value per lot must be expressed in the account currency (see §2). Note that leverage does not appear here — leverage governs margin, not risk. Two traders with the same stop and the same risk fraction take the same position size whether their account is 1:30 or 1:500; only their margin usage differs.
Worked example. Equity €10,000, risk 1% → risk_amount = €100. Trading EUR/USD with a 25-pip stop; pip value is €9.20 per standard lot. lots = 100 ÷ (25 × 9.20) = 100 ÷ 230 = 0.43 lots.
Tool: Position Size Calculator.
The value of one pip depends on three things: the pair, the lot size, and your account currency. The pip value in the quote currency is fixed by the contract size:
pip_value_quote = pip_size × contract_size × lots
most pairs: 0.0001 × 100,000 = 10 quote units per pip per standard lot
JPY pairs: 0.01 × 100,000 = 1,000 JPY per pip per standard lot
To express that in your account currency, multiply by the quote-to-account exchange rate:
pip_value_account = pip_value_quote × (account_per_quote_rate)
JPY pairs differ only in the pip size (0.01 instead of 0.0001) because one unit of most
base currencies has historically been worth roughly 100–300 JPY, so a fourth-decimal increment would be too small.
Worked example. 0.5 lots of GBP/JPY, account in EUR. Pip in JPY for one lot = 1,000; for 0.5 lots = 500 JPY. Convert at EUR/JPY = 165.00: 500 ÷ 165 ≈ €3.03 per pip.
Tool: Pip Value Calculator · concept: What is a pip?
Margin is the slice of equity the broker locks while a leveraged position is open.
notional_base = lots × contract_size
margin_base = notional_base ÷ leverage
margin_account = margin_base × (account_per_base_rate)
Worked example. 1 standard lot of EUR/USD at 1:30, USD account. notional = 100,000 EUR; margin = 100,000 ÷ 30 = 3,333.33 EUR; at EUR/USD = 1.164 that is ≈ $3,880. EU retail is capped at 1:30 on majors, US retail at 1:50.
Tool: Margin Calculator · concept: What is leverage?
As an open position moves, your equity changes but your used margin stays roughly fixed. The ratio of the two is the margin level; brokers force-close positions when it falls to the stop-out threshold (commonly 50%).
equity = balance + floating_pnl
margin_level = (equity ÷ used_margin) × 100%
stop_out when margin_level ≤ broker_threshold (e.g. 50%)
Concept: Margin call mechanics.
The reward-to-risk ratio compares how far your target is from entry against how far your stop is.
R = (target − entry) ÷ (entry − stop) # long
R = (entry − target) ÷ (stop − entry) # short
breakeven_winrate = 1 ÷ (1 + R) = risk ÷ (risk + reward)
expectancy (in R) = W × R − (1 − W)
A 1:2 setup (R = 2) breaks even at a 33.3% win rate; anything above that has positive expectancy.
Worked example. Long entry 1.1000, stop 1.0950, target 1.1100. R = (0.0100) ÷ (0.0050) = 2.0. Breakeven win rate = 1 ÷ 3 = 33.3%. At a 45% win rate, expectancy = 0.45 × 2 − 0.55 = +0.35R per trade.
Tool: Risk : Reward Calculator.
The Kelly criterion gives the bet fraction that maximises the long-run growth rate of capital. For a two-outcome
bet with win probability W and reward-to-risk ratio R:
f* = W − (1 − W) ÷ R
The forex-specific point traders get wrong: f* is the fraction of equity to put at risk per trade — the
risk_fraction in §1 — not the notional exposure and not a leverage setting. You feed f* into the
position-size formula as your risk %, and the stop distance converts it into lots. Leverage never appears in the Kelly
formula; it only has to be high enough to provide the margin for the resulting position. Confusing "bet a Kelly
fraction of capital" with "deploy a Kelly fraction of capital as margin" is what turns Kelly into account suicide at
high leverage.
Because W and R are estimated from a finite trade history, the raw f* is fragile: a small
overestimate of your edge produces a large overbet. Practitioners therefore scale down — fractional Kelly:
half-Kelly = f* ÷ 2
quarter-Kelly = f* ÷ 4
Half-Kelly captures about three-quarters of the growth rate of full Kelly with roughly half the volatility, which is why it is the common default. If f* ≤ 0 your edge is negative and the correct size is zero.
Worked example. W = 0.45, R = 2.0. f* = 0.45 − 0.55 ÷ 2 = 0.45 − 0.275 = 0.175, i.e. full Kelly says risk 17.5% of equity per trade — far too aggressive for real trading. Half-Kelly = 8.75%, quarter-Kelly = 4.4%, and most disciplined traders would cap this far lower still (often 1–2%).
Tool: Kelly Fraction Calculator.
Holding a position overnight earns or pays the interest-rate differential between the two currencies, adjusted by the broker's markup. The economic core is:
swap_per_night ≈ notional_base × (rate_long − rate_short − markup) ÷ 360
triple swap on the broker's 3-day-rollover weekday (usually Wednesday)
Actual swap points are set by each broker and drift from the pure differential; our calculator estimates the cost from the rate inputs you provide and applies the triple-swap multiplier on the rollover day. Treat the output as an estimate to compare against your broker's published swap table, not a quote.
Tool: Swap / Rollover Calculator.
The spread is the gap between bid and ask — a cost you pay on entry, embedded in the price. Per round trip:
cost_per_trade = spread_pips × pip_value_per_lot × lots
annual_cost = cost_per_trade × round_trips_per_year
Worked example. 1.2-pip spread, 1 standard lot of EUR/USD (pip value ≈ $10), 500 round trips a year: cost_per_trade = 1.2 × 10 = $12; annual = 12 × 500 = $6,000. Spread is the most underestimated cost in active trading.
Tool: Spread Cost Calculator.
The strength of a currency is its mean percentage change against its seven peers between two snapshots. For
currency C measured against peer X, using rates expressed as units-per-USD:
pct(C,X) = ( (now[X]/now[C]) ÷ (prior[X]/prior[C]) − 1 ) × 100
strength(C) = mean over the 7 peers X of pct(C, X)
A reading of +0.50% means the currency gained, on average, half a percent against the other majors.
The eight currencies covered are USD, EUR, GBP, JPY, CHF, AUD, CAD, NZD.
Tools: Currency Strength Meter (live) · Weekly Strength & Volatility Reports (archived).
Correlation is computed on daily log returns, not on raw prices, so that it measures co-movement independent of price level:
r_t = ln( price_t ÷ price_{t−1} )
corr(A,B) = Σ(rA−r̄A)(rB−r̄B) ÷ √( Σ(rA−r̄A)² · Σ(rB−r̄B)² )
That second line is the Pearson correlation coefficient over the rolling window (default 30 sessions). Crosses such as EUR/GBP are synthesised from their USD legs before returns are taken.
Tool: Pair Correlation Matrix.
frankfurter.dev.For the data pipeline, refresh cadence, and data structures behind these numbers, see the technical documentation.