Lot Size Script

Lot Size Script is a free script by DinexSpace for MT5. An MT5 script that calculates lot size from your risk percentage and stop distance.

Download .zipDetailed installation guide20.2 KB · 6 files · no sign-up

What Lot Size Script does

Lot Size Script is a free script by DinexSpace for MT5. An MT5 script that calculates lot size from your risk percentage and stop distance.

Lot Size Script answers one question before a trade: how many lots can I open so that hitting my stop loss costs exactly the risk I chose? Drop it on a chart, fill in two numbers and read the answer.

When to use it

Use it before every trade so you never risk more than you planned.

Features and modes

Lot Size Script has 6 documented features, listed below.

How it works

  • Risk is a percent of balance, a percent of equity, or a fixed amount in the account currency.
  • The stop loss is a distance in points or a stop-loss price. A price on the wrong side of the entry is rejected with a clear message.
  • The entry is the current ask (buy) or bid (sell) of the chart symbol.
  • The loss for 1.00 lot at the stop is the stop distance divided by the tick size, times the symbol's tick value on the loss side. That value comes from the terminal and already includes the conversion to the account currency.
  • The lot size is rounded down to the broker's lot step, so the money at risk is never above your choice.
    • If the result is below the minimum lot, the script says so instead of rounding up.
    • Above the maximum lot it is capped.
  • The result shows the lot size, risk after rounding, stop-loss price and the margin needed (calculated by the terminal), on the chart and in the Experts log.

Parameters

Lot Size Script has 7 inputs; every input and its default is listed below.

Risk measured as, risk value, direction, stop loss given as, stop distance in points, stop-loss price, show result on the chart.

Lot Size Script inputs – MT5 version
InputDefaultLabel in MT5
InpRiskInRISK_PCT_BALANCERisk measured as
InpRisk1.0Risk value (% or money)
InpSideSIDE_BUYDirection (for entry price and margin)
InpSlInSL_POINTSStop loss given as
InpSlPts300Stop distance (points)
InpSlPrice0Stop-loss price
InpCommenttrueShow the result on the chart (top-left comment)

Signals

Lot Size Script does not generate buy or sell signals. It is an analysis tool: you read what it plots and make your own decisions.

Alerts

No. Lot Size Script has no built-in alerts.

Buffers for Expert Advisors

No. Lot Size Script is an MT5 script that runs once; it has no indicator buffers.

Timeframes and markets

Lot Size Script sets no timeframe limit in its code: it runs on any chart timeframe and on the symbol of the chart it is attached to.

Limitations

Lot Size Script is an analysis tool, not a trading system. Its documented limitations are listed below.

  • The real fill price can differ from the current price used here, especially in fast markets.
  • Tick value can change with exchange rates.
  • The margin figure is for the current account and leverage.

The script only calculates. It never places, changes or closes orders, and uses no DLLs or web requests.

Lot Size Script FAQ

Lot Size Script is free, runs on MT5 and does not place trades.

Is Lot Size Script free?

Yes. Lot Size Script is free to download from this page with no sign-up, and the download includes the full source code.

Which platforms does Lot Size Script run on?

Lot Size Script is available for MetaTrader 5 (MQL5).

Does Lot Size Script give buy and sell signals?

Lot Size Script does not generate buy or sell signals. It is an analysis tool: you read what it plots and make your own decisions.

Does Lot Size Script have alerts?

No. Lot Size Script has no built-in alerts.

Can an EA read Lot Size Script?

No. Lot Size Script is an MT5 script that runs once; it has no indicator buffers.

Which timeframes does Lot Size Script work on?

Lot Size Script sets no timeframe limit in its code: it runs on any chart timeframe and on the symbol of the chart it is attached to.

Does Lot Size Script place trades?

No. It is a read-only script: it only reads market data and shows the result on the chart or writes it to a file. The source contains no calls that open, close or modify orders.

How do I install Lot Size Script?

Download the .zip and follow the step-by-step installation guide for MT5: https://indicators.dinexspace.com/install-guide/

Measured win rates (backtest)

Arrows and win rates are those of SuperTrend (the default source indicator). SuperTrend

  • Costs: Real spread of an ECN-type MT5 account, no commission.
  • Data source: MT5 tick data (BNB: Binance spot).

TradingView H4/D1 bars may follow the exchange time zone of the TradingView symbol, not the MT5 server time (UTC) used for the measurement; sessions and the H4 trend may differ on the Pine version. Same signals on TradingView not checked yet.

Past test statistics are not a promise of future results.

More in this category

All Risk Management indicators

ATR Stop Levels

Risk Management · Indicator

Plots reference stop-loss levels at ATR multiples above and below price. Use it to size stops by volatility instead of a fixed number of pips.

FreeMT5TradingViewMeasured

Correlation Matrix

Risk Management · Indicator

A table of correlation coefficients between the symbols you choose. Use it to avoid stacking positions that are really the same bet.

FreeMT5TradingViewMeasured

Drawdown Monitor

Risk Management · Indicator

Tracks drawdown from the peak: price drawdown on TradingView, account drawdown on MT5. Use it to know when to cut your position size.

FreeMT5TradingViewFilter tool

Risk-to-Lot Calculator

Risk Management · Indicator

Works out position size from the amount you are willing to lose and your stop-loss level. The MT5 version reads the symbol's real contract specifications and never places an order.

FreeMT5TradingViewUses SuperTrend