When an MT4 Expert Advisor uses a variable stop distance, a fixed lot size produces variable cash risk. A breakout strategy with a wider stop should generally allocate fewer lots if its intended cash risk is unchanged. This article separates the entry signal from a conservative position-sizing gate.
From stop distance to executable volume
Assume a USD account, a hypothetical EURUSD trade, a 35-pip stop, and a pip value of $10 per standard lot. The estimated price loss per lot is $350. With a $100 budget the theoretical size is 0.285714 lots. For a broker lot step of 0.01, round down to 0.28 lots, giving $98 estimated price risk. Rounding up to 0.29 would imply $101.50. A 0.30-lot order would imply $105. These figures exclude fees and execution differences.

Use symbol properties rather than a hardcoded pip multiplier
MarketInfo provides MODE_TICKSIZE, MODE_TICKVALUE, MODE_LOTSTEP, MODE_MINLOT and MODE_MAXLOT. The tick value is specified in deposit currency. Use the actual price distance divided by the symbol tick size, multiplied by tick value, to estimate loss per lot. Verify the broker's reported tick size and tick value against contract specifications, especially for CFDs and non-FX instruments. Do not assume that Point, a pip and a trade tick are interchangeable.
// MQL4 helper for the current chart symbol.
// entry and stop are actual price levels.
double RiskLots(double entry, double stop, double budget)
{
double tick = MarketInfo(Symbol(), MODE_TICKSIZE);
double value = MarketInfo(Symbol(), MODE_TICKVALUE);
double step = MarketInfo(Symbol(), MODE_LOTSTEP);
double minLot = MarketInfo(Symbol(), MODE_MINLOT);
double maxLot = MarketInfo(Symbol(), MODE_MAXLOT);
double distance = MathAbs(entry - stop);
if(tick <= 0 || value <= 0 || step <= 0 ||
distance <= 0 || budget <= 0 || minLot <= 0)
return 0;
double lossPerLot = distance / tick * value;
double raw = MathMin(maxLot, budget / lossPerLot);
double lots = NormalizeDouble(MathFloor(raw / step) * step, 8);
if(lots < minLot || lots > maxLot ||
lots * lossPerLot > budget)
return 0;
return lots;
}
The helper assumes a conventional zero-origin lot-step grid and positive, valid symbol properties. It returns zero when the risk budget cannot accommodate the minimum lot. The strict final budget comparison can conservatively reject a boundary size due to floating-point precision. Check the broker's actual volume grid before submission; do not silently increase volume to the minimum. This excerpt does not place orders.
Integrate with a breakout EA
- Confirm the breakout using a completed candle and prevent repeated entries for the same signal.
- Refresh quotes and calculate the intended entry and protective stop, using Ask for a market buy and Bid for a market sell. Validate stop direction and broker stop-distance restrictions.
- Reserve part of the total cash budget for estimated commissions and adverse execution, then pass the remaining price-risk budget to RiskLots.
- Check AccountFreeMarginCheck for the intended side and volume, and handle insufficient margin or invalid quotes. Margin availability is not equivalent to acceptable loss risk.
- Submit the order only if all gates pass. Check the returned ticket and error status. If execution differs from the estimate, reconcile actual fill and stop levels; avoid blind retries that could duplicate orders.
Test the boundaries
Use 20-, 35- and 70-pip stops with the same budget; estimated volume should decline as the stop widens. Test minimum-lot rejection, unusual lot steps, five-digit FX quotes, account currency conversion, insufficient margin and rejected stops. Compare estimated cash loss with tester trade records and demo-account executions. For simultaneous positions, allocate a separate portfolio risk budget rather than granting every signal the full account allowance.
A stop order is not a guarantee of maximum loss. Gaps, slippage, commissions, conversion changes and unreliable symbol properties can increase losses. This example has not been compiled or backtested here.
Official reference: Symbol properties. To customize this strategy idea, contact us about Custom MT4 strategy Development Services.