Skip to content
All library documents

Moving Average Crossover EA with Trend-Based Position Scaling

Article MQL5 code base

Summary

This document describes an Expert Advisor that trades crossovers between a faster and a slower moving average. A signal is evaluated when a bar closes: a move above the fast average triggers a buy, while a move below it triggers a sell. The EA can add volume to an existing position when the latest deal has gained more points than a user-defined threshold. It records the scale count and details of the latest deal in the trade comment.

The text explains that the compiled EA can bundle its indicator files as resources, allowing the executable to run without separate indicator files in the terminal folder. It also cites a GBPJPY four-hour test from 2015 using default inputs, with no stop loss or take profit. The referenced chart is not included in the text, and no performance figures or risk measures are supplied. The example therefore describes implementation and a test setup, but does not establish profitability or robustness; scaling into positions can also increase exposure.

Key ideas

  • The EA generates buy and sell signals from a fast and a slow moving average crossover at bar close.
  • It increases position volume when the latest deal exceeds a configurable profit threshold.
  • Trade comments record scaling information, including the number of additions and the latest deal details.
  • The compiled EA can include its indicator files as embedded resources.
  • The cited GBPJPY test used four-hour bars in 2015 and omitted stop loss and take profit; the text gives no performance statistics.

Tags

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