Watch how to download trading robots for free
Find us on Twitter!
Join our fan page
Interesting script?
So post a link to it -
let others appraise it
You liked the script? Try it in the MetaTrader 5 terminal
Experts

Risk Lot Size Calculator Panel - expert for MetaTrader 5

Cristhian Alexander Gaibor Cuasquer
Cristhian Alexander Gaibor Cuasquer
  • Founder & Systems Engineer at  Xander Pro
  • Ecuador
  • 7838
4.7 (40)
Trader and MQL5 member since 2017.
Views:
63
Rating:
(1)
Published:
MQL5 Freelance Need a robot or indicator based on this code? Order it on Freelance Go to Freelance

Lot size on Gold (XAUUSD), forex, indices or crypto comes from two numbers you type on the chart: the risk, as a percent of balance, a percent of equity or a fixed amount, and the stop loss in points. The loss of 1.00 lot at that stop is taken from OrderCalcProfit, so the figure is right on gold, indices and cross pairs, not only on EURUSD.

The lot is rounded down to the broker volume step and capped by the broker maximum and your own maximum. The BUY and SELL buttons open the trade at market with the stop and the take profit already attached, after a free margin check and a check of the broker minimum stop distance.

Rounding down means the money really at risk can be a little below your number, and the panel shows both. If the risk is too small for the broker minimum lot, it refuses the trade unless you allow the minimum. Try it on a demo account first.

Risk Lot Size Calculator Panel on a XAUUSD chart in MetaTrader 5 showing the lot for 1 percent risk with a 300 point stop and the BUY and SELL buttons

Settings

  • Risk mode and risk per trade: percent of balance, percent of equity or money. The mode can also be changed with the button on the panel.
  • Stop loss and take profit in points. On a gold quote with 2 decimals 300 points is a 3.00 USD move, with 3 decimals it is 0.30 USD. Take profit 0 means no target.
  • Use the minimum lot: off by default. On, a lot below the broker minimum is raised to the minimum and the real risk is shown.
  • Never send more than: your own lot cap. Default 5.0.
  • Refuse a trade that risks more than: percent of balance. Default 5.
  • Magic number, max deviation, order comment, panel position and font size.

What it needs

Hedging or netting account, any symbol, any broker. It only opens a trade when you press BUY or SELL. It never closes or modifies positions.

Make it yours

Put it on XAUUSD, EURUSD, GBPUSD, US30, NAS100 or BTCUSD and watch how the loss per lot changes from one symbol to another for the same stop. XP_LossPerLot and the rounding in XP_Recalc are ready to copy into any EA that needs risk based lots, and the panel is plain on purpose so you can add your own buttons, a breakeven or a partial close.

About this code

Open source. Use it as it is, adapt it, build your own version on top of it.

New versions and new tools are announced first on my MQL5 channel: https://www.mql5.com/en/channels/xander

Questions, suggestions and your own backtests are welcome in the Xander Lab group: https://www.mql5.com/en/messages/02eec85e4364dd01

More tools on my profile: https://www.mql5.com/en/users/09151993a

Provided as is, use at your own risk.

Related

Changelog

  • v1.0 - 2026-11-02 - Initial release
Liquidity Sweep Equal Highs Lows Liquidity Sweep Equal Highs Lows

Liquidity indicator for MT5 on Gold (XAUUSD), forex and indices: equal highs and equal lows from swings, marked as swept when a wick runs the level and the candle closes back. Open source code.

Fair Value Gap Zones Tracker Fair Value Gap Zones Tracker

Fair value gap (FVG) indicator for MT5 on Gold (XAUUSD), forex and indices: three candle gaps on closed bars, ATR size filter, the open part shrinks as price fills it, mitigation by touch, midline or full fill. Open source code.

Accelerator Oscillator (AC) Accelerator Oscillator (AC)

The Acceleration/Deceleration Indicator (AC) measures acceleration and deceleration of the current driving force.

MACD Signals MACD Signals

Indicator edition for new platform.