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
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
Parameters
| Parameter | Default | Description |
|---|---|---|
INDENT_LEFT | 11 | Left indent in pixels |
INDENT_TOP | 11 | Top indent in pixels |
INDENT_RIGHT | 11 | Right indent in pixels |
INDENT_BOTTOM | 11 | Bottom indent in pixels |
CONTROLS_GAP_X | 5 | Horizontal spacing between controls in pixels |
CONTROLS_GAP_Y | 5 | Vertical spacing between controls in pixels |
BUTTON_WIDTH | 100 | Button width in pixels |
BUTTON_HEIGHT | 20 | Button height in pixels |
EDIT_HEIGHT | 20 | Edit box height in pixels |
GROUP_WIDTH | 150 | Group width in pixels |
LIST_HEIGHT | 179 | List height in pixels |
RADIO_HEIGHT | 56 | Radio button height in pixels |
CHECK_HEIGHT | 93 | Checkbox height in pixels |
pause | true | Pause flag for timer toggle state |
Similar Utility EAs
Backtests are historical simulations and do not guarantee future results. Not financial advice.