How it works
An EA is a compiled MQL4 or MQL5 program attached to a chart. It runs in a loop on every new tick, checks the strategy’s entry, exit, and risk rules, and sends orders through the platform’s order interface. The EA can only act on the data and broker connection MetaTrader exposes; anything outside that environment is invisible to it.
What an EA typically codes
- Entry logic: indicator crossovers, price-action triggers, time-based opens
- Position sizing: fixed lot, percentage risk, or volatility-adjusted
- Stop and target: hard stops, trailing stops, breakeven shifts
- Exit rules: opposite signal, time stop, profit lock-in
- Filters: session, news avoidance, volatility regime
Example
A trend-following EA on EUR/USD H1: open long when 20 EMA crosses above 50 EMA and ADX is above 25, position size 1 percent of equity, stop 2 ATR below entry, take profit at 4 ATR, trail stop after 2 ATR profit. The EA monitors the chart 24/5 and fires whenever conditions hit. No emotion, no missed signals, no late entries. Whether the strategy is profitable is a separate question entirely.
Why it matters
Automation removes the two biggest sources of trader error: hesitation and discretion. It does not add edge that is not already in the rules. A bad strategy automated is just a bad strategy executed faster. Before running any EA on live capital, test on at least 5 years of historical data across different market regimes, then forward-test on a demo account for a month. The first two weeks of live trading always surprise.