Back to contents

Magic Entry · MT5 trade manager

Lot size from risk in MT5: how Magic Entry calculates the volume

You set the risk as a percentage of the balance or as an amount in the account currency, then place the stop on the chart: Magic Entry calculates the lot so that a stop-out loses that risk. In % and $ modes the volume already accounts for the commission you enter in the settings and, for sells, the spread. The lot is rounded to the broker’s minimum lot and lot step, so the real risk can differ slightly from the target.

% $ Lots Fixed Lots

Risk mode

The mode button switches how volume is calculated: %, $, Lots and Fixed Lots.

How to set the risk

  1. In the Inputs tab (F7), enter your broker’s round-turn commission per 1 lot in Comission (Round); leave Spread ON.
  2. On the entry panel at the top of the chart, click the mode button until it shows % (percent of balance) or $ (money amount).
  3. Type the risk into the field next to it, for example 1 for 1% or 100 for $100. The value is remembered per chart.
  4. Press LIMIT or MARKET and click the stop on the chart: the volume is calculated from that stop, and the hint banner under the panel checks it.
  5. For a volume you choose yourself, switch to Lots; for MetaTrader-style BUY and SELL buttons without a stop, switch to Fixed Lots.

Example: EURUSD, $100 risk, 100-point stop

Without costs, a 100-point stop on EURUSD with $100 risk gives 1.00 lot. With a $7 round-turn commission entered, Magic Entry opens 0.93 lot instead: the stop then costs $93 plus $6.51 commission, still within $100.

For a sell with Spread ON and a 30-point spread, the stop is placed the spread above your click, so the same $100 covers 130 points and the volume is 0.76 lot instead of 1.00. A buy needs no correction: it enters at Ask, and the spread is already inside its stop.

  • Labels on the chart show the loss including commission and the profit already net of it.
  • In Lots and Fixed Lots modes the volume does not change; commission is counted only in the amounts.
  • If the risk is smaller than the broker’s minimum lot allows, the trade cannot be opened for exactly that amount: the advisor opens the volume nearest to the risk that the broker permits.

Advisor inputs for this function

Set on the Inputs tab (F7) when you attach Magic Entry to a chart. Captions and defaults are the advisor’s own.

  • Comission (Round)COMISSION_PER_LOTDefault: 0.0

    Broker commission per round turn (open and close) per 1 lot, in account currency. In % and $ modes the advisor reduces volume so that the loss at the stop plus commission doesn't exceed the risk.

    • Example: EURUSD, risk $100, stop 100 points, commission $7 — volume 0.93 instead of 1.00. The stop costs $93 plus $6.51 commission.
    • Every label shows loss including commission, and profit already net of it.
    • In Lots and Fixed Lots modes the volume doesn't change: commission is counted only in the amounts.
    • The advisor doesn't get commission from the broker: enter it yourself. At 0, commission isn't counted anywhere.
  • SpreadSPREAD_CONTROLDefault: ON

    MetaTrader draws candles by Bid, but a sell closes at Ask — a spread above the candles. So a sell stop can trigger even though the candle never reached the line. If on, the advisor places the sell stop the current spread above the click and recalculates volume for the same risk.

    • A buy doesn't need this: it enters at Ask, so the spread is already inside its stop.
    • The wider the spread, the smaller the volume, while the money at risk stays the same: with a 100-point stop and a 30-point spread — 0.76 lots instead of 1.00.
    • An open position's take profit can't be set closer to price than the spread: for a buy — not below Ask plus spread, for a sell — not above Bid minus spread. Breakeven and trailing also keep a spread's distance.
    • Turn it off and the stop lands exactly at the click point, but the spread can knock a sell out.

    OFFSpread OFF: stop at the click point

    ONSpread ON: stop a spread higher

  • Calculate Limit activation marginCALC_LIMIT_MARGINDefault: ON

    Limit and stop orders only. If on, the advisor checks in advance whether there will be enough free margin when the order fills; if not, it reduces the volume and shows MARGIN MAX. Turn it off and the check follows the broker's rules for pending orders, so an oversized order may be rejected when it triggers.

Other Magic Entry functions