Skip to content
All library documents

Building an MA and ADX Trend-Following Expert Advisor in MQL5

Article MQL5 articles

Summary

The document teaches beginners how to structure an MQL5 Expert Advisor around a simple trend-following rule. The example looks for an upward or downward moving average and a closing price on the corresponding side, then uses ADX strength and direction as a trend filter. It specifies stop-loss and profit-target inputs, evaluates entries on new bars, and avoids opening a duplicate position in the same direction. The walkthrough also introduces EA inputs, global variables, indicator handles, initialization and cleanup, and tick-event processing.

The article describes compiling and debugging the EA and using the Strategy Tester to compare settings across pairs and timeframes. It offers an example test process, but the supplied excerpt gives no dependable evidence of general profitability. The author says further adjustments are needed before real trading, so the example is best treated as a programming and testing tutorial, not a validated strategy.

Key ideas

  • The example buys or sells according to moving-average slope and the bar close's position relative to the average.
  • ADX acts as a filter intended to keep the EA out of non-trending conditions.
  • Inputs make indicator periods and trade protection settings adjustable.
  • The EA checks for opportunities on new bars and limits duplicate same-direction positions.
  • Strategy Tester results across settings require further evaluation before real use.

Tags

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