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
Scripts

Position Size Calculator - risk-based lot sizing script - script for MetaTrader 5

Dror Munk
Dror Munk
I build robust, fully-tested MetaTrader Expert Advisors and indicators in MQL5 and MQL4, with a focus on safe execution and honest validation — not just code that compiles, but code that behaves correctly under real conditions.
What you get from an order:
Views:
86
Rating:
(1)
Published:
MQL5 Freelance Need a robot or indicator based on this code? Order it on Freelance Go to Freelance

Run the script on the chart of the symbol you plan to trade, enter how much you are willing to risk - a percent of equity or a fixed amount in your account currency - and your stop-loss distance, either in points or as a concrete price level, and it returns the lot size.


The calculation uses the symbol's real contract specification: tick size and tick value for the money-per-point math, and volume min/max/step for normalization. The result is rounded DOWN to the volume step, so the actual risk never exceeds your budget; the script reports the exact risk at the normalized size. It also estimates the required margin for the planned direction via OrderCalcMargin and warns clearly when the position would exceed your free margin, when the calculated size falls below the symbol minimum (i.e. even the minimum lot risks more than your budget), or when it must be capped at the symbol maximum.


The full report is printed to the chart Comment, the Experts journal, and a one-line Alert. Works on forex pairs, metals, indices and any symbol with valid contract specifications. It calculates only - it never places orders.



Spread Monitor Panel - live spread with spike alerts Spread Monitor Panel - live spread with spike alerts

On-chart panel with the live spread of the chart symbol - current, minimum, average and maximum since attach - color-coded against your warning and danger thresholds, plus an optional alert when the spread stays at the danger level for N consecutive seconds (news and rollover spikes).

Prop Firm Risk Dashboard - daily loss and drawdown monitor Prop Firm Risk Dashboard - daily loss and drawdown monitor

A read-only on-chart panel that tracks your account against a daily-loss limit and a max-drawdown limit, with color-coded OK / WARNING / DANGER status. Monitoring only - it does not place, modify or close any orders.

Trade Journal Exporter - closed positions to CSV Trade Journal Exporter - closed positions to CSV

Exports your closed positions for a configurable period to a CSV file for journal analysis in Excel or Google Sheets: entry and exit time and price (volume-weighted over partial fills), volume, result in points, commission, swap, net profit and trade duration.

Market Structure SMC: Swings, BOS/CHoCH, Order Blocks, FVG, QML Market Structure SMC: Swings, BOS/CHoCH, Order Blocks, FVG, QML

SMC/ICT market-structure indicator for MT5: swing highs/lows, BOS (continuation) and CHoCH (reversal) confirmed on close, Order Blocks, Fair Value Gaps, and QML (Quasimodo) levels. Every feature is toggle-able, with adjustable swing sensitivity and colors. Works on any symbol and timeframe.