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

Risk-Based Lot Size Calculator - script for MetaTrader 5

ALI RAJPUT
Published by:
Rana Ali
Rana Ali
  • MQL5 Developer & Algorithmic Trading Specialist at  Freelance
  • Pakistan
  • 10
Views:
71
Rating:
(1)
Published:
MQL5 Freelance Need a robot or indicator based on this code? Order it on Freelance Go to Freelance


The Risk-Based Lot Size Calculator is a lightweight MQL5 script that removes the guesswork from position sizing. Instead of manually working out how many lots to trade, you enter a risk percentage and a stop loss distance, and the script instantly reports the correct lot size for the current symbol and account balance.


Many traders lose money not because their strategy is wrong, but because their position size is wrong. Risking too much on a single trade can damage an account even with a good strategy, while risking too little limits growth. This script ties position size directly to a fixed percentage of account risk, so every trade carries a consistent, controlled amount of risk.

External variables used:
InpRiskPercent - the percentage of account balance you are willing to risk on the trade (default 1.0%).
InpStopLossPips - the distance between entry price and stop loss, measured in pips (default 20 pips).

How it works: the script reads the current account balance together with the selected symbol's tick value, tick size and volume constraints (minimum lot, maximum lot, lot step). It then works out the lot size needed so that, if price moves against you by the specified number of pips, the loss equals the chosen risk amount. The result is rounded down to the nearest allowed lot step and clamped between the broker's minimum and maximum volume. The final lot size, together with the full calculation breakdown, is shown on the chart and printed to the Experts log.

Because it reads live broker parameters instead of relying on hard-coded pip values, the script works on any symbol and any account type. Simply attach it to a chart, enter the risk percentage and stop loss in pips, and read the suggested lot size from the chart comment.
Correlation-Aware Lot Size Calculator Correlation-Aware Lot Size Calculator

Sizes your next trade based on the correlated risk you already have open across other positions — not just the trade in isolation.

Prop Firm Rule Checker Prop Firm Rule Checker

Checks your trade history against common prop-firm challenge rules — profit target, max daily loss, max drawdown, consistency rule, and minimum trading days — with a clear PASS/FAIL report.

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.