How to Create and Edit an MT5 Expert Advisor (2026)
Short answer: To create an Expert Advisor in MetaTrader 5, use the MQL5 Wizard in MetaEditor (no code), write MQL5 from a template, or design visually and export MQL5. To edit an EA, open its .mq5 file, change logic or inputs, recompile (F7), and attach the new .ex5 to a chart. Always enable AutoTrading and test in Strategy Tester before live trading.
This guide maps three proven paths aligned with MetaTrader 5 algorithmic trading documentation and the MQL5 language reference โ so you can choose what fits your time, skills, and goals.
Choose Your Path: Wizard, Code, or No-Code
| Path | Best for | You write MQL5? | Typical time to first test |
|---|---|---|---|
| MQL5 Wizard | Beginners who want a rule-based EA fast | No (generated) | 30โ60 minutes |
| MetaEditor (template) | Full control, learning, custom logic | Yes | 1โ3 days (with tutorials) |
| No-code builder + export | Visual thinkers, repeatable strategies | No (export) | 1โ2 hours |
If you are unsure, start with the Wizard or no-code path to see an EA run in Strategy Tester, then move to hand-coded MQL5 when you need logic the Wizard cannot express.
Create an EA with the MQL5 Wizard
MetaTrader 5 includes a MQL5 Wizard that generates Expert Advisor source code from your choices (signals, money management, trailing). MetaQuotes describes it in Creating Expert Advisors in the MQL Wizard: traders without programming skills can select indicators and modules, and the Wizard produces compilable code.
Steps (official workflow)
- Open MetaEditor โ In MT5: Tools โ MetaQuotes Language Editor, or press F4.
- New file โ File โ New (or Ctrl+N) โ choose Expert Advisor (generate) โ Next.
- Name your EA โ e.g.
MyFirstWizardEAโ Next. - Select signals โ Pick modules (e.g. moving average, RSI) and configure periods per the Wizard screens.
- Money management & trailing โ Set lot rules or accept defaults โ Finish.
- Compile โ Press F7; fix any errors until 0 errors in the Build tab.
- Run in MT5 โ In Navigator โ Expert Advisors, drag the EA onto a chart โ allow Algo Trading โ enable AutoTrading.
For a walkthrough with screenshots and signal combinations, see MQL5 Wizard for Dummies on MQL5.com.
Limitation: Wizard EAs follow predefined modules. For unique multi-timeframe rules or custom filters, use code or a visual builder that exports structured MQL5.
Create or Edit EA Code in MetaEditor
Hand-written MQL5 gives maximum flexibility. The MQL5 Reference is the authoritative API documentation; Build Your First EA walks through a complete MA crossover example.
Create from template
- MetaEditor โ File โ New โ Expert Advisor (template) โ name โ Finish.
- You receive
OnInit(),OnDeinit(),OnTick()โ the standard event model described in Expert Advisors. - Add input parameters (lot size, periods, magic number).
- Implement signals and call
OrderSend()or theCTradeclass โ see our MQL5 programming reference. - Compile (F7) โ attach
.ex5to chart.
A classic beginner walkthrough: Step-by-Step Guide to writing an Expert Advisor in MQL5 for Beginners.
Edit an existing EA
- Locate the
.mq5file under MQL5/Experts/ (or your broker folder). - Open in MetaEditor; change inputs, conditions, or risk rules.
- Recompile; MT5 loads the new
.ex5when you re-attach or refresh. - Version control: rename or backup before large edits โ compare behavior in Strategy Tester.
Pair edits with EA risk management (position size, SL/TP) before going live.
Build an EA Without Writing MQL5
A visual strategy builder lets you define indicators, entry/exit rules, and risk in a form-based UI, then export production-ready MQL5. That fits traders who want automation without maintaining thousands of lines of code.
Workflow:
- Define strategy logic (timeframes, buy/sell rules, filters).
- Export MQL5 source.
- Compile in MetaEditor (or use exported package).
- Backtest in Strategy Tester โ Demo โ optional VPS for 24/7.
Read the full comparison in Build an MT5 EA Without Coding. Try the Strategy Builder demo to prototype before export.
How to Edit an Existing Expert Advisor
| Source of EA | How to edit |
|---|---|
| Wizard-generated | Edit .mq5 in MetaEditor; avoid re-running Wizard on same file (overwrites). |
| Downloaded (.ex5 only) | You need the .mq5 source; without it, only inputs exposed as EA properties are changeable. |
| No-code export | Change rules in the builder โ re-export โ recompile. |
| Commercial EA | Only if vendor provides source or editable inputs; respect license terms. |
After any edit: compile โ backtest โ Demo โ same discipline as a new EA.
Test, Compile, and Validate Before Live
MetaQuotes and industry best practice: never skip historical testing.
- Compile โ 0 errors in MetaEditor (setup guide).
- Strategy Tester โ Realistic spread, correct symbol, sufficient history (backtest guide).
- Demo account โ Forward behavior with live ticks.
- Live โ Small size; monitor Journal and common errors.
Next Steps
- New to EAs? What Is an Expert Advisor
- Setup MT5 & MetaEditor: MQL5 Environment Setup
- First coded EA: Build Your First EA
- No-code path: Build EA Without Coding
- Deploy safely: Deploy and Maintain Your EA
- Prop / funded accounts: Prop Firm EA Rules
- Using ChatGPT for code: Can ChatGPT Write an MT5 EA?
References: MetaTrader 5 โ How to Create an Expert Advisor, MQL5 Documentation, MQL5 Wizard (article), Expert Advisor template (book).