Skip to content
All library documents

Moving-Average Breakout EA with Trailing Pending Orders

Article MQL5 code base

Summary

This expert advisor is built on the idea that price crossing a moving average and traveling a specified distance may continue in that direction. It places Buy Stop and Sell Stop pending orders, then updates their distance from a long-period moving average at set time intervals. The EA trails pending orders only; after an order becomes a position, it no longer modifies that position. Inputs include stop loss, take profit, trailing step, distance from the moving average, update timeout, and a unique identifier.

The document reports one-year M1 backtest results across several currency pairs, with widely varying outcomes: some pairs were profitable while others had losses and substantial equity drawdowns. This variation is evidence that the approach’s results depended heavily on the instrument in the reported tests. The table does not establish robustness beyond its stated period and setup, and the document gives no broader validation or explanation of transaction costs, parameter selection, or out-of-sample performance.

Key ideas

  • The EA places stop orders in the direction of price movement after price crosses a long-period moving average and moves a specified distance.
  • Pending orders are adjusted periodically to maintain their distance from the moving average.
  • Once triggered, positions are not modified by the EA’s trailing logic.
  • The reported results differ substantially across currency pairs and include large drawdowns on some instruments.
  • The backtest covers a limited period and does not establish performance in other market conditions.

Tags

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