Skip to content
All library documents

Higher-Timeframe Moving Average Crossovers with Reversible Trades

Article MQL5 code base

Summary

This Expert Advisor uses the relationship between moving averages calculated on two timeframes. When the current timeframe’s average crosses the higher-timeframe average upward, it signals a long entry; a downward cross signals a short entry. A new signal opens the corresponding position and closes the opposing one. The EA calculates the averages internally, can reverse the signals, and accepts settings for trade size, stop loss, take profit, slippage, and spread-based stop distance. It also adjusts invalid stop distances and oversized lots to symbol or account limits, skipping a trade if even the minimum lot cannot be funded.

The document reports a test over January 2017 to January 2018 in which default settings performed poorly. Reversing the trades improved the reported outcome, and optimization of the higher-timeframe moving-average period from 1 to 20 selected 8 for maximum balance. These results are limited to the stated test period and optimization objective. No out-of-sample validation, drawdown analysis, transaction cost assumptions, or broader robustness evidence is given, so the selected setting should not be treated as generally reliable.

Key ideas

  • The strategy signals trades when moving averages from the current and a higher timeframe cross.
  • Each new signal opens the corresponding side and closes the opposing position.
  • The EA can reverse signals and includes configurable stops, targets, volume, and slippage.
  • The reported test favored reversed trades and selected a higher-timeframe period of 8 for maximum balance.
  • The evidence covers one stated historical interval and does not establish out-of-sample robustness.

Tags

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