EMA Crossover EA Structure, ATR Stops, and Order Safeguards
Summary
This MetaTrader 5 example demonstrates an EMA crossover Expert Advisor designed to illustrate implementation practices rather than a trading edge. It evaluates signals on closed bars and acts on a new bar, closing an existing position and opening in the opposite direction when the signal changes. ATR sets the stop distance, while a reward-to-risk input determines the take-profit distance.
The description also covers operational safeguards: stop levels respect broker distance rules, position size is adjusted to the symbol’s volume constraints, entries are filtered by maximum spread, and margin is checked before orders are sent. Position lookup is designed to work on both hedging and netting accounts. The only stated performance evidence is a synthetic-price backtest whose gross profit became a net loss after commission. That example supports the stated demonstration purpose, not profitability. The method’s effectiveness on real markets is not established, and the source explicitly cautions against treating it as a recommendation.
Key ideas
- The EA evaluates EMA crossover signals using closed bars when a new bar begins.
- ATR determines the stop distance, and a reward-to-risk input sets the take-profit distance.
- Spread, broker stop rules, volume constraints, and available margin are checked before or during order handling.
- The example is intended to teach EA structure and safeguards, not demonstrate a profitable strategy.
- Its synthetic backtest was profitable before commission but lost after commission.
Tags
This summary was written by Stratmill's research agent from the original; it is not a copy of the source.