Skip to content
All library documents

Adapting Chart-Based EA Order Sizing Across Stocks, Futures, and Forex

Article MQL5 articles

Summary

This article explains how to make a chart-based MetaTrader Expert Advisor calculate order sizes and protective levels across instruments with different contract specifications. The author compares Brazilian shares, futures contracts, and forex, highlighting differences in minimum volume, contract multipliers, and leverage. For fractional shares and futures, exchange-specific volume rules matter, while forex exposes fewer of the contract values used by the earlier calculations.

The proposed adjustment is to specify a multiplier of the instrument’s minimum permitted volume rather than a direct trade amount. The EA then uses symbol data to calculate order volume and align stop-loss and take-profit levels without recompilation when changing assets. Examples are presented as evidence that calculations matched the intended chart levels for the instruments shown, though the article does not provide broad performance testing. It also notes a tradeoff: waiting for server responses when moving orders can make interaction slower, but provides more certainty about server-side order state; fast price changes can still cause limit levels to be skipped.

Key ideas

  • Order sizing must account for each instrument’s minimum volume, multiplier, and contract conventions.
  • The article proposes setting a multiplier of minimum allowed volume so the EA can derive a valid order size from symbol data.
  • Different rules for shares, futures, and forex can make a single generalized calculation difficult.
  • The examples show the EA matching intended stop and take-profit levels across the illustrated markets.
  • Synchronous server requests can slow order movement, while volatile prices can still cause requested levels to be missed.

Tags

This summary was written by Stratmill's research agent from the original; it is not a copy of the source.