EA-51877 · Utility

Maximum Trade Volume

This EA is a utility tool that displays a dialog panel on the chart showing the maximum lot sizes available for buy, sell, pending buy, and pending sell orders based on the current free margin. It does not open any trades itself; it merely calculates and presents margin-based lot size information to the trader.

Open the interactive view (equity curve, symbol switch)

Key facts

CategoryUtility
RiskSafe
Rating★★☆☆☆
TypeUtility tool
TimeframesM1, M5, M15, M30, H1, H4, D1, W1, MN
Indicators—
Author—

Backtest results (H1, about 1 year)

Not backtested yet — this EA could not be converted automatically.

Strategy analysis

This EA is not a trading strategy but a margin calculation utility tool. Its core concept is to compute the maximum lot size available for each order type (buy, sell, pending buy, pending sell) based on the account's free margin and current market prices. Entry and exit conditions are not applicable since it does not execute trades. Position sizing logic uses the OrderCalcMargin function to determine the margin required for 1 lot, then divides the available free margin by the per-lot margin requirement to derive the maximum lot size, rounding down to the nearest valid lot step via MathFloor. Money management relies on AccountInfoDouble(ACCOUNT_MARGIN_FREE) to obtain the current free margin as the calculation basis, and uses SymbolInfoDouble to fetch the symbol's minimum lot, maximum lot, and lot step for normalization. However, there is a critical bug: in LotCheckPendingBuy and LotCheckPendingSell, the '||' operator is used to combine two order type enum values, which performs a bitwise OR operation producing an invalid enum value rather than a logical selection. Additionally, the calculated lot size is never clamped against SYMBOL_VOLUME_MAX, so it may return values exceeding the broker's maximum allowed lot size.

Strengths

  • Provides an intuitive GUI panel displaying maximum available lot sizes for each order type, enabling traders to make quick decisions
  • Uses the OrderCalcMargin function for margin calculation, which is the officially recommended MQL5 method and provides good accuracy
  • Lot size normalization accounts for minimum lot and lot step, preventing invalid order sizes
  • Covers four common order types: buy, sell, pending buy, and pending sell, providing comprehensive information

Weaknesses

  • LotCheckPendingBuy and LotCheckPendingSell use the '||' operator to combine enum values, which performs a bitwise OR operation instead of logical selection, resulting in an invalid OrderCalcMargin call
  • The calculated maximum lot size is never compared against SYMBOL_VOLUME_MAX upper limit, potentially returning values exceeding the broker's maximum allowed lot
  • Displayed values are only calculated once when the panel is created and do not automatically update when market conditions or margin changes
  • The 'static' keyword on lotSize variables is unnecessary, and all four LotCheck functions have highly duplicated logic with no code reuse
  • The timer functionality (pause variable) is created but not actually used in any logic, making it dead code

Possible improvements

  • Fix the enum value bug in OrderCalcMargin calls: pending buy should use ORDER_TYPE_BUY_STOP and pending sell should use ORDER_TYPE_SELL_STOP (or calculate each pending order type separately)
  • Add SYMBOL_VOLUME_MAX upper bound check to ensure calculated results never exceed the broker's maximum allowed lot size
  • Implement timer-driven auto-refresh functionality, leveraging the existing OnTimer and pause variable to periodically update the displayed values on the panel
  • Refactor the four duplicated LotCheck functions into a single parameterized utility function to reduce code redundancy

Risk assessment

Overall risk: Safe

  • Pending order margin calculation uses invalid enum values produced by bitwise OR, which may cause OrderCalcMargin to return incorrect results, leading to inaccurate displayed maximum lot sizes
  • No comparison with SYMBOL_VOLUME_MAX upper limit means displayed values may mislead traders into attempting orders that exceed broker limits

Evaluation scores

Code quality2.0
Strategy logic1.0
Risk management3.0
Robustness2.0
Innovation2.0
Documentation1.0
Overall1.8

Parameters

ParameterDefaultDescription
INDENT_LEFT11Left indent in pixels
INDENT_TOP11Top indent in pixels
INDENT_RIGHT11Right indent in pixels
INDENT_BOTTOM11Bottom indent in pixels
CONTROLS_GAP_X5Horizontal spacing between controls in pixels
CONTROLS_GAP_Y5Vertical spacing between controls in pixels
BUTTON_WIDTH100Button width in pixels
BUTTON_HEIGHT20Button height in pixels
EDIT_HEIGHT20Edit box height in pixels
GROUP_WIDTH150Group width in pixels
LIST_HEIGHT179List height in pixels
RADIO_HEIGHT56Radio button height in pixels
CHECK_HEIGHT93Checkbox height in pixels
pausetruePause flag for timer toggle state

Similar Utility EAs

Backtests are historical simulations and do not guarantee future results. Not financial advice.

Get the weekly Arena report

One email a week: ranking changes, new signals and new research. No spam; unsubscribe any time.