How the calculator works
Margin = Lots × Contract size × Price / Leverage — the amount comes out in the quote currency and is converted into the account currency. For forex this is the MetaTrader 5 formula «lots × contract / leverage» in the base currency, converted at the pair's price; for metals and leveraged CFDs it is the help formula as is. The MetaTrader 5 help example: 1 lot of EURUSD at 1:100 leverage is 1,000 euros, or $1,279 at a rate of 1.2790 — the calculator gives the same amount.
Free margin = Equity − Margin— what new trades are opened with;Margin level = Equity / Margin × 100%;Room to a threshold = Equity − Margin × Threshold / 100— for margin call and stop out;Room in pips = Room / (Lots × Pip value per lot).
Check it against the example
The calculator opens with the article's example — a $2,000 account, 1 lot of EURUSD at 1.08, 1:100 leverage, a 100% margin call and a 50% stop out — and shows $1,080 of margin, a 185.19% margin level and 92 pips of room to the margin call and 146 to the stop out; the step-by-step breakdown is in «Margin, leverage, margin call and stop out explained».
When a rate is needed
If the quote currency — the second currency of the pair — matches the account currency (EURUSD or XAUUSD on a dollar account), no rate is needed. If the pair itself converts the quote currency into the account currency (USDJPY on a dollar account, EURUSD on a euro account), the calculator uses its price. Otherwise a rate field appears: USDJPY for EURJPY on a dollar account, GBPUSD for EURGBP. Take the price and the rate from your terminal: the site does not fill in quotes itself, so margin is never calculated from a stale price.
Leverage changes margin, not risk
The table below the calculator shows the same position at leverage from 1:10 to 1:1000: the higher the leverage, the smaller the margin and the further away the stop out, while at low leverage the margin may exceed equity. The loss per pip is the same at any leverage — it is shown under the table.
Trade risk is set by volume and the distance to the stop. First decide what share of the account you are ready to lose and size the position from the stop loss in the lot size calculator; the formula and common mistakes are in «How to calculate lot size: formula and examples». Here, check that the stop loss sits closer than the room to the stop out in pips — otherwise the server closes the position before the stop.
How Davinchu watches margin
The Davinchu Trade Monitor EA for MetaTrader 5 tracks the room to the thresholds for open positions and your account's own levels: the dashboard on the chart shows the margin level and how many points of price movement are left to margin call and stop out — MT5 points, not the pips used on this page (on a five-digit EURUSD quote, 10 points = 1 pip). The EA sends equity, free margin and margin level to your Davinchu web dashboard — they are in the «Current risk» block on the «Statement» page.
«Margin alerts» send a message when the margin level drops below your threshold, again with every further step down, and once more when the level recovers above the threshold. The defaults are a 500% threshold and a 100% step; the alerts are turned on in the «EA settings» tab of the account settings. The stop out message is on by default and shows the margin level, the account's stop out level and equity. Messages reach Telegram, email or Discord; the below-threshold alert and the stop out message are critical — they arrive during quiet hours too.
Position size from risk is calculated by the T-Manager risk manager for MetaTrader 5 (from the Plus plan): risk in money or as a percent of balance, equity or free margin. Monitoring connects accounts at any forex and CFD broker on MetaTrader 4 and 5, including prop firms — see «Account monitoring». The Free plan connects two accounts at no cost.