Watch how to download trading robots for free
Find us on Facebook!
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 Calculator - expert for MetaTrader 5

Pavel Polikarpov
Pavel Polikarpov
  • Директор at  Мотосервисе
  • Russia
  • 169
Энтузиаст который познает технологии!
Views:
68
Published:
MQL5 Freelance Need a robot or indicator based on this code? Order it on Freelance Go to Freelance

Risk Lot Calculator is a small MetaTrader 5 utility. It shows, on the chart, a lot size that matches a chosen risk percent and a stop-loss distance in points. It also shows tick value, tick size, required margin and the money at risk at the calculated lot. The utility does not place, modify or close orders.

What the panel shows

  • Symbol and timeframe of the chart.
  • Account equity, balance and the reference used for risk (equity or balance).
  • The risk setting: a percent, or a fixed money amount if that input is greater than zero.
  • Stop-loss in points, also expressed as a price distance. A point is one unit of the symbol's _Point.
  • Tick size and tick value in the account currency.
  • Point size and contract size.
  • Minimum lot, maximum lot and lot step.
  • Broker StopsLevel.
  • Loss per 1.00 lot at the given stop.
  • Calculated lot, rounded down to the lot step and limited by the symbol minimum and maximum.
  • Money at risk at that lot.
  • Margin per 1.00 lot and margin for the calculated lot, using OrderCalcMargin for a buy at the current ask.
  • Free margin, with a warning if the calculated lot would not fit.

If the stop is closer than StopsLevel, if the risk is too small for the minimum lot, if the lot was capped at the symbol maximum, or if free margin is insufficient, the panel shows a warning in red. The footer states that the utility does not place orders.

The panel updates on a timer (500 milliseconds if the terminal allows it, otherwise once per second) and when a new tick arrives.

Inputs

Calculation

  • Risk per trade, percent of the reference balance (default 1.0).
  • Stop-loss distance in points, in symbol _Point units (default 200). On XAUUSD, if _Point is 0.01, 200 points is a $2.00 price move.
  • Use equity (true) or balance (false) as the reference.
  • Fixed money risk: if greater than 0, this amount is used instead of the percent.

Panel

  • Show or hide the panel.
  • Corner and pixel offsets.
  • Font size and colours.

How the lot is calculated

  • Risk money is reference * risk percent / 100, or the fixed money input when it is greater than zero.
  • Stop distance in price is stop points * _Point.
  • Loss per 1.00 lot is (stop distance / tick size) * tick value.
  • Raw lot is risk money / loss per 1.00 lot.
  • The lot is rounded down to the symbol lot step and then clamped to the minimum and maximum lot. If the result is below the minimum lot, the panel reports that the risk is too small.

This is a sizing aid only. It does not check news, spread, or your trading rules, and it does not send orders.

Requirements

  • Platform: MetaTrader 5.
  • Works on any symbol that provides tick size, tick value and margin data.
  • No DLL calls, no WebRequest and no internet connection.
  • Attach the Expert Advisor to one chart. It does not trade, so it can sit on the same chart as a separate trading Expert Advisor; it will not open a position of its own.

About the author

Published by the author of Golden Sniper XAU:
https://www.mql5.com/en/market/product/207995

Risk warning

Trading in financial markets involves a high level of risk and can lead to the loss of the entire deposit. Position size is only one part of risk. This utility does not guarantee that a calculated lot is suitable for your account, broker or strategy.

Author of Golden Sniper XAU: https://www.mql5.com/en/market/product/207995

AlgoFX Session Liquidity Sweeps AlgoFX Session Liquidity Sweeps

Marks previous day, Asian and London session highs and lows from chart bars and flags closed-bar, ATR-filtered liquidity sweeps. Non-repainting, with EA-readable buy/sell buffers and an on-chart display panel.

Round-Number / Psychological Level Magnet Round-Number / Psychological Level Magnet

Auto-scaled round-number grid for any symbol — big figures and half levels drawn to the right spacing whether you're on EURUSD, USDJPY, XAUUSD or an index, plus a live "distance to nearest magnet" readout.

ICT Session Boxes - four GMT windows, automatic broker offset, high and low lines ICT Session Boxes - four GMT windows, automatic broker offset, high and low lines

Session windows are quoted in GMT; the chart runs on the broker's clock. This indicator takes each window in GMT, applies your broker's offset, and draws the box over that window's bars. It adds the high and low lines to every enabled window unless you switch them off, prints the session name and range only on that session's newest box when there is room, and never trades.

Risk-Based Lot Size Calculator (script) Risk-Based Lot Size Calculator (script)

A small script that turns "risk in % of the account" and "stop loss in pips" into a lot size. It only calculates and prints; it never opens, modifies or closes trades.