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
Scripts

Lot Size Calculator - Risk Percent to Lots - script for MetaTrader 5

Views:
18
Rating:
(1)
Published:
MQL5 Freelance Need a robot or indicator based on this code? Order it on Freelance Go to Freelance

Lot Size Calculator is a script that works out the position size for a given risk and stop-loss distance. Run it on any chart, enter how much you want to risk and where the stop is, and it shows the lot size to use. It only calculates: it never opens, modifies or closes trades.

The money value of the stop distance is taken from OrderCalcProfit(), the same function the terminal uses, so the result is correct for forex, cross pairs, gold, indices and crypto, whatever the account currency. If OrderCalcProfit() is not available for a symbol, the script falls back to tick size and tick value. The lot is rounded down to the symbol's volume step and kept within the minimum and maximum volume.

Input parameters

  • Risk mode - % of balance, % of equity, or a fixed amount in account currency.
  • Risk - the percent or the amount, depending on the mode.
  • Trade direction - buy (entry at Ask) or sell (entry at Bid).
  • Stop loss distance (points) - used when the stop price is 0.
  • Stop loss price - exact stop price; 0 = use the distance in points.

Input parameters

Input parameters

Result

  • Entry and stop prices and the distance in points.
  • Risk target and the value of 1.0 lot moving to the stop.
  • Lot size, the actual risk at that lot size, and the margin required.
  • A warning when even the minimum lot risks more than the limit.

Calculation result

Result for a 1% risk buy on XAUUSD with a 200-point stop

Candle Timer and Spread Candle Timer and Spread

Shows the time left until the current candle closes and the live spread in any chart corner. Keeps counting every second, even when no ticks arrive.

Close All Positions and Orders (Filtered) Close All Positions and Orders (Filtered)

Closes open positions and deletes pending orders in one run, with filters for symbol, magic number, side and profit or loss. Asks for confirmation and retries failed closes.

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.