Blog

What Is an Expert Advisor (EA) in Forex Trading?

TradeSmithy Team4 min read

Short answer: an Expert Advisor (EA) is a program that runs inside MetaTrader 4 or MetaTrader 5 and trades automatically by rules. It is written in MQL4 or MQL5, compiled to an .ex4 or .ex5 file, attached to a chart, and from then on it reads prices and indicators, opens and closes trades, and manages stops without you clicking anything.

"Forex robot" and "trading bot" usually mean the same thing. This guide explains how an EA actually runs, how it differs from an indicator or a script, and the four ways to get one.

How does an Expert Advisor work?

An EA is event-driven. MetaTrader calls functions in it when something happens:

EventWhen it firesTypical use
OnInitWhen the EA is attached or the terminal restartsCreate indicator handles, check inputs
OnTickOn every new price quote for the chart's symbolCheck conditions, open or manage trades
OnTimerOn a schedule you setPeriodic checks independent of ticks
OnDeinitWhen the EA is removed or the chart closesClean up

Most strategies live in OnTick. Many check whether a new candle has formed first, so that decisions are made once per closed bar rather than dozens of times a second — this is what the "OnNewCandle" event in a visual builder does.

For an EA to trade, three switches must all be on: the terminal's Algo Trading button (called AutoTrading in MT4 and in older MT5 builds), the EA's own "Allow Algo Trading" setting, and your account must permit automated trading. If any is off, the EA runs but cannot place orders — the single most common reason people think their EA is broken.

Expert Advisor vs indicator vs script

ProgramCan trade?RunsUse it for
Expert AdvisorYesContinuously, on eventsAutomated strategies and trade management
IndicatorNoOn every price updateCalculating and drawing values on a chart
ScriptYesOnce, then stopsOne-off actions such as "close all trades"
Service (MT5 only)YesIndependently of any chartBackground tasks such as custom data feeds

An indicator cannot open a trade, which is why "turn my indicator into an EA" is such a common request. The EA calls the indicator — built-in ones through functions such as iRSI or iMA, your own through iCustom — and acts on its values. We explain how in using your own custom indicator in an Expert Advisor.

What can an EA do?

Anything a trader can do in the terminal, repeatably:

  • Enter on conditions — an RSI below 30, a moving-average crossover, a breakout of the previous high.
  • Exit by stop loss, take profit, trailing stop, opposite signal or time.
  • Size each position from account balance and stop distance instead of a fixed lot. Here is how.
  • Filter trades by spread, volatility, or the number of positions already open.
  • Protect the account with equity or drawdown limits.

What can't an EA do?

  • It cannot find an edge. It executes the strategy you give it, good or bad.
  • It cannot run on the MetaTrader mobile app. EAs need the desktop terminal running — on your computer or a VPS.
  • It cannot guarantee live results match the backtest. Spread, slippage and fills differ. See our honest answer on making money with a trading bot.

How do you get an Expert Advisor?

  1. Buy one. Fast, but you inherit someone else's logic, usually as a compiled file you cannot inspect.
  2. Hire a developer. Good for complex strategies; expect to pay per revision.
  3. Code it yourself in MQL. Full control, and weeks of learning — MQL4 and MQL5 are different languages.
  4. Build it visually. Assemble the rules as a graph and export real MQL source. That is what TradeSmithy does; the walkthrough is here.

Build your first Expert Advisor

If you can describe your entry and exit in a sentence, you can build it. Start free on TradeSmithy: pick a template, change the rules on the canvas, and export an .mq4 or .mq5 you compile in MetaEditor like any other EA. The Free plan includes the full builder and one export a month; Pro adds the AI assistant and server-side backtests.

Frequently asked questions

Is an Expert Advisor the same as a trading bot?

Yes. Expert Advisor is MetaTrader's name for an automated trading program; trading bot and forex robot describe the same thing.

Do Expert Advisors work on both MT4 and MT5?

Each EA is written for one. An MT4 EA (.ex4) will not run on MT5, and vice versa. A builder that generates both languages lets you target either.

Do I need to leave my computer on for an EA to work?

Yes, the terminal must be running and connected. Traders who run EAs full time usually use a VPS.

Are Expert Advisors allowed by brokers?

Most brokers allow them. Some restrict specific techniques such as latency arbitrage or very high-frequency scalping, so check your account terms.

Keep reading

← More from the TradeSmithy blog