EMA Crossover EA with ATR Stops and Percent-of-Equity Risk Sizing
Summary
This educational MQL5 Expert Advisor uses a fast and slow EMA crossover on the last two closed bars to generate entries once per new bar. It places a stop at an ATR-based distance, subject to the broker’s minimum stop distance, and sets a take profit as a multiple of that stop distance. Position size is calculated so that a stop-out targets a chosen fraction of account equity, using estimated trade profit and broker volume limits to derive and round the lot size.
Before placing an order, the example checks spread and whether the EA already has a position on the symbol under its magic number. It also reports the server return code when an order is rejected. Suggested defaults include EMA periods of 20 and 50, an ATR period of 14, a two-ATR stop, a 1.5 reward-to-risk target, and 0.5% equity risk per trade. The document presents a template, not a tested profitable system; commissions, slippage, and price gaps can make realized losses differ from the target.
Key ideas
- The EA checks for EMA crossovers using the last two closed bars on each new bar.
- It sets an ATR-based stop and a take profit based on a multiple of the stop distance.
- Position size targets a specified percentage of equity at risk, subject to broker volume constraints.
- Spread and existing positions are checked before an order is sent.
- Commissions, slippage, and gaps can cause realized risk to differ from the target.
Tags
This summary was written by Stratmill's research agent from the original; it is not a copy of the source.