Skip to content
All library documents

Building a Configurable Expert Advisor with Reusable Trading Controls

Article MQL5 articles

Summary

This article explains how to assemble a MetaTrader 5 Expert Advisor from reusable functions and configurable inputs. Its constructor approach centralizes trade execution checks, indicator setup, signal handling, and position or pending order management. A position structure holds both the intended trade parameters and transaction state, while signal search creates an order request and a transaction callback tracks its execution. The examples include standard and custom indicator integration and signal logic based on a moving average indicator.

The configurable controls cover stop loss, take profit, trailing behavior, fixed or risk-based lot sizing, time windows, allowed trade direction, position limits, reversing signals, closing opposing positions, and pending order constraints such as spread and expiration. The article illustrates the workflow with example Expert Advisors for market positions and pending orders. It offers implementation guidance rather than a measured comparison of outcomes: no backtest or live performance evidence is supplied, and the example framework still requires strategy-specific signal logic and adaptation to the relevant symbol and trading conditions.

Key ideas

  • A shared position structure can carry both trade parameters and the state needed to confirm order execution.
  • An Expert Advisor can search for signals on every tick or only when a new bar forms.
  • The framework exposes fixed-lot and risk-percentage sizing alongside stop, target, and trailing controls.
  • Pending-order settings can constrain spread, expiration, order count, reversal, and replacement of existing orders.
  • The article demonstrates software architecture and controls but does not report strategy performance.

Tags

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