Your plan, made executable — what Expert Advisors actually are
An EA is not magic and not a black box. It is your trading plan written in a language MT5 can run. This lesson shows exactly what that means.
Dernière révision :
The 90-second version
An EA is your trading plan running as code. It doesn't think — it executes. That's a feature, not a bug.
- EA = rules you write → MT5 runs them 24/5 without emotions or fatigue
- A backtest shows how the rules performed on past data — it doesn't predict the future
- Most retail EAs fail live because they were tuned to pass a backtest, not to trade
- The craft is in writing rules that hold up in conditions they were never tested on
- You can automate any strategy that can be described as: IF [condition] THEN [action]
By 2024 nearly every prop firm challenge was being attempted with an EA — and nearly every EA that passed still failed the live phase.
Avec l'explosion des challenges de prop firm en 2024, le marché des « EA pour passer le challenge » a explosé lui aussi — optimisés pour briller sur les données historiques, pas pour trader. Le schéma était constant : backtest brillant, compte réel en ruine.
SourceEA Anatomy Explorer
Click any layer to see what it does, what can go wrong there, and a concrete example.
What an EA actually is
A recipe that cooks itself
Imagine you have a precise cooking recipe: 'If the oven hits 200°C and the timer rings, take the dish out.' You could follow that yourself, or you could hand the recipe to a kitchen robot that watches the thermometer and the clock. The robot follows the recipe exactly — every time, without getting tired, distracted, or deciding to improvise.
An Expert Advisor is that robot. The recipe is your trading strategy: entry conditions, stop-loss placement, take-profit level, lot sizing, and exit rules. You write the recipe once (or choose one someone else wrote). MT5 runs it on a live chart around the clock.
This is the only honest way to think about automation: it replaces human execution of a defined plan. It does not replace the plan. If the plan is poor, the automation makes it poor at scale and speed.
The four layers of any EA
Every EA — from a €5 download to a professionally coded institutional system — is made of the same four components stacked on top of each other. Understanding each layer tells you exactly where an EA can go wrong.
Layer 1 — Signal: reads price (and optionally volume, news events, other indicators) and decides 'should I be looking to buy or sell right now?'
Layer 2 — Filter: checks whether conditions are appropriate to act on the signal. Common filters: is volatility within normal range? Is the current session right? Is there a high-impact news event in the next 30 minutes?
Layer 3 — Risk: calculates lot size based on current account equity and the defined stop-loss distance. This is the layer that protects capital.
Layer 4 — Execution: sends the order to the broker, manages the open position (trailing stop, partial close), and closes it according to exit rules.
Why backtest ≠ future performance
A backtest runs your EA's rules against historical price data and shows what would have happened. It is an essential development tool. It is also the most misunderstood number in retail trading.
The problem is selection bias. When you build an EA, you tweak parameters until the backtest looks good. But 'looks good on past data' only means the rules fit that specific data set — the same way a key fits a specific lock. Put the key in a different lock and it won't turn.
The measure of a real EA is the walk-forward test: train it on one period of data, then run it unseen on the next. If it holds up across multiple unseen periods, you have something worth testing on a demo account. We will do this step-by-step in Lesson 7.
Key terms
A story from 2024
In 2024 the prop-firm challenge industry exploded — and with it, a generation of EAs built to pass a backtest, not to trade.
Avec l'explosion des challenges de prop firm en 2024, le marché des « EA pour passer le challenge » a explosé lui aussi — optimisés pour briller sur les données historiques, pas pour trader. Le schéma était constant : backtest brillant, compte réel en ruine.
The pattern was consistent: a builder would optimise an EA on 2 years of historical data, see a 180% return and a 5% drawdown in the tester, pay the challenge fee, pass, get funded — and then watch the EA lose 8% in its first month of live trading. The rules had been so perfectly tuned to the last 2 years that they had zero margin for any new price behaviour. Lesson 7 of this course shows the exact technique that separates those EAs from ones that actually hold up.
SourcePractice
Map your own trading plan to EA layers
This is the most important first step before you ever open the MT5 strategy tester. Take the trading plan you built in Forex Basics Lesson 11 (or any rule-based approach you use) and map it to the four EA layers.
- 1
Write down your entry condition in one sentence starting with 'IF'. Example: 'IF the RSI crosses above 30 AND price is above the 50 EMA...' If you can't write it as an IF statement, it isn't automatable yet.
- 2
Add at least one filter: a session window, a volatility check, or a news blackout period. Unfiltered signals are the #1 cause of EA blowups.
- 3
Define your risk rule as a number: '1% of current account equity per trade, based on the distance to my stop-loss.' This is your Risk layer.
- 4
Write your exit: TP at X pips, SL at Y pips, or trailing stop. No 'I'll close when it feels right' — that cannot be automated.
- 5
Keep this written-down map. Every lesson in this course will attach to one of those four layers. By Lesson 6 you'll be able to run your own rules in MT5's strategy tester.
Mastery check
Four questions. Pass at 75% (3/4). The point is not to memorise — it's to catch any gap before Lesson 2.
Mastery check — Lesson 1
Testez vos connaissances avec 4 questions. Réussite avec 75/4 bonnes réponses.
Reflect
Réflexion
Notez vos réponses honnêtes — sauvegardées uniquement sur cet appareil. Reprenez-les la semaine prochaine pour repérer des tendances dans votre façon de penser le trading.
Pro deep dive
The four-layer model is pedagogically clean. Professional EA architecture is somewhat more complex. Here is the fuller picture.
The event-driven execution model
MT5 calls EA functions in response to events: OnTick() fires on every new price tick; OnBar() fires on every completed candle; OnTimer() fires at a fixed interval; OnTradeTransaction() fires when the broker confirms a fill. Most retail EAs only use OnTick() or OnBar(), which is fine for strategies that don't need sub-second precision. Scalpers and latency-sensitive strategies need to understand that OnTick() is called for every quote update — at busy news releases that can mean hundreds of calls per second.
The order pipeline: EA → terminal → broker
When an EA calls OrderSend() (or the v2 trade functions), the instruction travels from the EA's MQL5 code → MT5 terminal → broker's execution server → liquidity provider. Each handoff introduces latency and possible slippage. The EA has no control over what happens after OrderSend() returns — only over the parameters it sends. This is why Lesson 8 (Execution & Infrastructure) matters: the quality of the connection between your terminal and your broker's server directly affects how closely live execution matches backtest execution.
Why the 4-layer model breaks down in grid and martingale EAs
Grid EAs and martingale EAs deliberately violate the Risk layer: they increase lot size after losses (martingale) or open a grid of orders at fixed pip intervals regardless of risk. These strategies can show excellent backtests — especially on instruments that range — because the test data inevitably 'recovers.' In live trading, when the market trends for an extended period, both grid and martingale EAs face geometrically increasing drawdowns. This is not a bug in the code; it is the strategy's fundamental design. Understanding this at Layer 3 level lets you evaluate any grid EA critically rather than just looking at its backtest equity curve.
MQL5 quick reference — a first look
MQL5 code for a minimal EA entry signal looks like: if (iMA(NULL, 0, 20, 0, MODE_EMA, PRICE_CLOSE, 0) > iMA(NULL, 0, 50, 0, MODE_EMA, PRICE_CLOSE, 0)) { // Signal: 20 EMA above 50 EMA — consider long }. The function iMA() reads an indicator value from the chart. The parameters define which instrument, timeframe, period, and type. If this looks complex, don't worry — Lesson 4 dissects an EA input by input without requiring you to write any MQL5 yourself.
Sources
Afficher la réponse
Signal (reads price → directional opinion), Filter (checks conditions are right to act), Risk (sizes the position to protect capital), Execution (sends the order and manages the trade).
Matériel éducatif uniquement — ce ne sont pas des conseils en investissement. Le trading comporte un risque de perte en capital. Entraînez-vous toujours sur un compte démo et utilisez un stop-loss. ← Retour à Automated Trading