What Is an Expert Advisor (EA)? A Plain-Language Introduction for Rule Builders
An expert advisor is a program that runs your written trading rules on MetaTrader 4 or 5. This guide explains how rules become code, what an EA cannot do, and how to study one responsibly.
If you can describe a trading idea as a sentence, you can describe it as a rule. An expert advisor (EA) is the program that takes such a rule into a trading platform and follows it without getting tired, distracted or impatient. This guide explains what an EA is, how your written logic becomes code, and — just as important — what an EA cannot do for you.
Key takeaways
- An EA is software that follows rules you defined in advance.
- It does not predict the market and it cannot repair a weak strategy.
- The practical benefit is consistency: identical logic, identical steps, every time.
- You stay responsible for risk settings, symbols, sessions and when to switch it off.
- Study behaviour on historical data and on a demo account before considering live use.
What exactly is an expert advisor?
An expert advisor is a small application that runs inside a trading platform, watches the market for you and acts when your conditions are met. On MetaTrader 4 the language is MQL4, on MetaTrader 5 it is MQL5. The same logic can be expressed elsewhere as Pine Script for TradingView, Python for research and data work, or C# for cTrader and NinjaTrader. The platform differs; the idea does not: if condition A and condition B are true, then do action C with risk R.
A visual strategy builder such as Lupuso lets you assemble that logic as connected blocks — indicators, conditions, entries, exits, risk, sessions, trade management — on a canvas, then export it as source code for the target platform. You are still writing rules. You are simply writing them as a diagram instead of as syntax.
How do written rules become EA code?
The path is always the same, whether you type the code yourself or generate it from blocks.
- You state the logic in unambiguous terms: what to look at, what counts as true, what to do next.
- Each threshold becomes a parameter. In Lupuso, the variables and constants window turns every number into an input, so a stop distance or a session start time can be changed later without rewriting the logic.
- The builder validates the structure before export, so incomplete chains or contradictory settings are flagged instead of silently exported.
- The export produces source code you can compile or paste into the platform.
The rule below is deliberately boring, and that is the point. A computer needs boring precision.
IF close[1] > EMA(50)[1]
AND ATR(14)[1] > 0
THEN open a buy
stop distance = 2 x ATR(14)[1]
target = 3 x ATR(14)[1]
trade only between 08:00 and 17:00 server timeNotice the details that a human would fill in by feel: the bar shift ([1] means the last closed bar), the reference time zone, and what happens when two signals arrive together. Those are exactly the details an EA needs spelled out.
What an EA does not do
This is the part worth reading twice.
- An EA does not know the future. It reacts to data that already exists.
- It does not understand news, context or intent. It compares numbers.
- It does not manage your account. Risk size, maximum daily loss, and when to stop belong to you.
- It does not turn a losing rule into a winning one by automating it. Automation removes hesitation, not negative expectancy.
- It does not remove platform reality: spread, slippage, requotes, gaps and connectivity still apply.
Why consistency is the real benefit
Most discretionary traders do not fail because one rule was wrong. They fail because the rule was applied differently on Tuesday than on Friday. An EA applies the same definition every time: the same bar shift, the same indicator values, the same session filter, the same position size formula. That consistency also makes the strategy inspectable. When you can read the exact rule, you can argue about the rule instead of about memory.
How do you study an EA responsibly?
Use the built-in backtest simulator to see how the logic behaved on historical data, then treat the output as a description of the past rather than a forecast. Sensible next steps are running the same logic on a demo account, keeping a small trade count so the sample is meaningful, and writing down the conditions under which you would switch the EA off. A rule-based approach makes this easier, because the off-switch can itself be a rule.
Common mistakes
- Switching an EA on the day it was built, without historical testing or a demo period.
- Adjusting thresholds repeatedly until the historical report looks pleasant — that is curve fitting, not improvement.
- Ignoring costs. Spread, commission and slippage are part of the rule, not an afterthought.
- No predefined stop conditions: no maximum daily loss, no maximum consecutive losses, no review date.
- Stacking many indicators in the belief that more conditions equal more robustness. Usually it equals more curve fitting.
- Forgetting the time zone. A session block written in local time but executed on broker server time is a different strategy.
Risk note
Trading carries a real risk of loss, and automation does not reduce that risk — it can make losses arrive faster because execution no longer waits for you. Backtests describe how a rule behaved on data that has already happened; they are not predictions and they contain no promise about future results. Templates and examples are starting points for your own study, not trading signals or financial advice. Decide your position size, your maximum acceptable loss and your stop conditions before anything runs, and review them on a schedule you set in advance.
English · Español · Français · Deutsch · Português · 中文 · العربية · हिन्दी · 9 supported locales
