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. Compare paths in MQL5 Wizard vs Strategy Builder.
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. On AlfaTactix, Mana AI can help fill those Strategy Builder steps in plain language — it is not a raw ChatGPT MQL5 dump into MetaEditor.
Workflow:
- Define strategy logic (timeframes, buy/sell rules, filters) — try the demo first.
- Create a free account when you want to save, then export MQL5 from Code Generator.
- Compile in MetaEditor (or use exported package).
- Backtest in Strategy Tester → Demo → optional VPS for 24/7.
Read the full tour in Build an MT5 EA Without Coding.
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).

